feat: aggregate line-level customer notes into order note and force visibility of customer_note field in POS orders
This commit is contained in:
parent
93ac66fa5b
commit
f205e94c2b
@ -20,6 +20,7 @@ Features
|
|||||||
'depends': ['point_of_sale', 'pos_restaurant'],
|
'depends': ['point_of_sale', 'pos_restaurant'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/res_config_settings_views.xml',
|
'views/res_config_settings_views.xml',
|
||||||
|
'views/pos_order_view.xml',
|
||||||
],
|
],
|
||||||
'assets': {
|
'assets': {
|
||||||
'point_of_sale._assets_pos': [
|
'point_of_sale._assets_pos': [
|
||||||
|
|||||||
@ -72,3 +72,24 @@ class PosOrder(models.Model):
|
|||||||
'has_real_orders': bool(real_orders),
|
'has_real_orders': bool(real_orders),
|
||||||
'order_count': len(real_orders),
|
'order_count': len(real_orders),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _process_order(self, order, existing_order):
|
||||||
|
"""
|
||||||
|
Override to automatically concatenate orderline customer notes into the
|
||||||
|
general_customer_note so they are easily visible on the backend.
|
||||||
|
"""
|
||||||
|
if 'lines' in order:
|
||||||
|
line_notes = []
|
||||||
|
for line in order['lines']:
|
||||||
|
if len(line) >= 3 and isinstance(line[2], dict) and line[2].get('customer_note'):
|
||||||
|
line_notes.append(line[2]['customer_note'].strip())
|
||||||
|
|
||||||
|
if line_notes:
|
||||||
|
combined_notes = " / ".join(line_notes)
|
||||||
|
if order.get('general_customer_note'):
|
||||||
|
order['general_customer_note'] = f"{order['general_customer_note']} / {combined_notes}"
|
||||||
|
else:
|
||||||
|
order['general_customer_note'] = combined_notes
|
||||||
|
|
||||||
|
return super(PosOrder, self)._process_order(order, existing_order)
|
||||||
|
|
||||||
|
|||||||
14
views/pos_order_view.xml
Normal file
14
views/pos_order_view.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="view_pos_pos_form_inherit_pos_ui_optimization" model="ir.ui.view">
|
||||||
|
<field name="name">pos.order.form.inherit.pos_ui_optimization</field>
|
||||||
|
<field name="model">pos.order</field>
|
||||||
|
<field name="inherit_id" ref="point_of_sale.view_pos_pos_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<!-- Change customer_note on order lines to be visible by default -->
|
||||||
|
<xpath expr="//field[@name='lines']/list/field[@name='customer_note']" position="attributes">
|
||||||
|
<attribute name="optional">show</attribute>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Loading…
Reference in New Issue
Block a user