sale_usability: track changes in delivered_qty in the chatter
This feature is native in the purchase module in v14. I consider that it replaces the 3 modules service_line_qty_update_base/service_line_qty_update_purchase/service_line_qty_update_sale
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
'views/account_move.xml',
|
||||
'views/res_company.xml',
|
||||
"views/res_partner.xml",
|
||||
"views/sale_template.xml",
|
||||
'wizards/sale_invoice_discount_all_lines_view.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
|
||||
@@ -135,3 +135,29 @@ class SaleOrderLine(models.Model):
|
||||
if no_product_code_param and no_product_code_param == 'True':
|
||||
product = product.with_context(display_default_code=False)
|
||||
return super().get_sale_order_line_multiline_description_sale(product)
|
||||
|
||||
# In v12, I developped the 3 modules service_line_qty_update_base, service_line_qty_update_purchase
|
||||
# and service_line_qty_update_sale that add a wizard to update service lines and track the changes
|
||||
# in the chatter.
|
||||
# In v14, you can edit the quantity of the service lines directly and the purchase module
|
||||
# tracks changes in the chatter... but the sale module doesn't track the changes of 'qty_delivered'
|
||||
# So I "ported" that native feature of the purchase module to sale.order.line... here it is !
|
||||
# We can remove that code if this feature is added in the sale module (it's NOT the case in
|
||||
# odoo v17)
|
||||
def write(self, vals):
|
||||
if 'qty_delivered' in vals:
|
||||
for line in self:
|
||||
line._track_qty_delivered(vals['qty_delivered'])
|
||||
return super().write(vals)
|
||||
|
||||
def _track_qty_delivered(self, new_qty):
|
||||
self.ensure_one()
|
||||
prec = self.env['decimal.precision'].precision_get('Product Unit of Measure')
|
||||
if (
|
||||
float_compare(new_qty, self.qty_delivered, precision_digits=prec) and
|
||||
self.order_id.state == 'sale'):
|
||||
self.order_id.message_post_with_view(
|
||||
'sale_usability.track_so_line_qty_delivered_template',
|
||||
values={'line': self, 'qty_delivered': new_qty},
|
||||
subtype_id=self.env.ref('mail.mt_note').id
|
||||
)
|
||||
|
||||
16
sale_usability/views/sale_template.xml
Normal file
16
sale_usability/views/sale_template.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
|
||||
<template id="track_so_line_qty_delivered_template">
|
||||
<div>
|
||||
<strong>The delivered quantity has been updated.</strong>
|
||||
<ul>
|
||||
<li><t t-esc="line.name"/>:</li>
|
||||
Delivered Quantity: <t t-esc="line.qty_delivered" /> -> <t t-esc="float(qty_delivered)"/><br/>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user