First working version of service_line_qty_update_*

This commit is contained in:
Alexis de Lattre
2020-05-29 23:21:54 +02:00
parent 5c7985a15c
commit 28be3e4e6a
5 changed files with 29 additions and 18 deletions

View File

@@ -10,7 +10,11 @@
'summary': 'Update delivery qty on service lines - Purchase module',
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['purchase'],
'depends': [
'purchase',
'service_line_qty_update_base',
'purchase_reception_status',
],
'data': [
'views/purchase_order.xml',
],

View File

@@ -14,7 +14,7 @@
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<button name="action_view_invoice" position="after">
<button name="%(service_line_qty_update_base.service_qty_update_action)d" type="action" string="Update Service Qty" attrs="{'invisible': ['|', ('state', 'not in', ('purchase', 'done')), ('has_service', '=', False)]}"/>
<button name="%(service_line_qty_update_base.service_qty_update_action)d" type="action" string="Update Service Qty" attrs="{'invisible': ['|', '|', ('state', 'not in', ('purchase', 'done')), ('has_service', '=', False), ('reception_status', '=', 'received')]}" groups="purchase.group_purchase_user"/>
<field name="has_service" invisible="1"/>
</button>
<xpath expr="//field[@name='order_line']/tree/field[@name='qty_received']" position="attributes">

View File

@@ -24,8 +24,11 @@ class ServiceQtyUpdate(models.TransientModel):
'purchase_line_id': l.id,
'product_id': l.product_id.id,
'name': l.name,
'name_readonly': l.name,
'order_qty': l.product_qty,
'order_qty_readonly': l.product_qty,
'pre_delivered_qty': l.qty_received,
'pre_delivered_qty_readonly': l.qty_received,
'uom_id': l.product_uom.id,
}))
if lines:
@@ -44,14 +47,15 @@ class ServiceQtyUpdateLine(models.TransientModel):
def process_line(self):
po_line = self.purchase_line_id
if po_line:
po_line.write({'qty_received': self.post_delivered_qty})
new_qty = po_line.qty_received + self.added_delivered_qty
po_line.write({'qty_received': new_qty})
body = """
<p>Received qty updated on service line <em>%s</em>:
<p>Received qty updated on service line <b>%s</b>:
<ul>
<li>Added received qty: %s</li>
<li>Added received qty: <b>%s</b></li>
<li>Total received qty: %s</li>
</ul></p>
""" % (self.added_delivered_qty, self.post_delivered_qty)
""" % (self.name, self.added_delivered_qty, new_qty)
if self.comment:
body += '<p>Comment: %s</p>' % self.comment
po_line.order_id.message_post(body=body)