diff options
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 10 | ||||
| -rwxr-xr-x | indoteknik_custom/views/purchase_order.xml | 6 |
2 files changed, 16 insertions, 0 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 1eb76370..7091bb72 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -215,6 +215,16 @@ class PurchaseOrder(models.Model): else: self.approval_status = 'pengajuan1' + def re_calculate(self): + for line in self.order_line: + sale_order_line = self.env['sale.order.line'].search([ + ('product_id', '=', line.product_id.id), + ('order_id', '=', line.order_id.sale_order_id.id) + ], limit=1, order='price_reduce_taxexcl') + for so_line in sale_order_line: + unit_price = line.price_unit + so_line.purchase_price = unit_price + def button_cancel(self): res = super(PurchaseOrder, self).button_cancel() self.approval_status = False diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 5b0c99ef..918e130c 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -59,6 +59,12 @@ </page> <field name="fiscal_position_id" position="after"> <field name="note_description"/> + <field name="total_so_percent_margin"/> + <button name="re_calculate" + string="Re Calculate" + type="object" + attrs="{'invisible': [('approval_status', '=', 'approved')]}" + /> </field> </field> </record> |
