|
| 1 | +<?xml version='1.0' encoding='UTF-8'?> |
| 2 | +<odoo> |
| 3 | + <record id="automate_sipplier_info" model="ir.actions.server"> |
| 4 | + <field name="name">Automate the supplier info cost</field> |
| 5 | + <field name="model_id" ref="purchase.model_purchase_order"/> |
| 6 | + <field name="base_automation_id" ref="base_automation_1"/> |
| 7 | + <field name="state">code</field> |
| 8 | + <field name="code"><![CDATA[ |
| 9 | +for line in record.order_line: |
| 10 | + product = line.product_id |
| 11 | + if product.categ_id.x_automate_cost_update: |
| 12 | + supplier_info = env['product.supplierinfo'].search([ |
| 13 | + ('product_tmpl_id', '=', product.product_tmpl_id.id), |
| 14 | + ('partner_id', '=', record.partner_id.id) |
| 15 | + ], limit=1) |
| 16 | +
|
| 17 | + if supplier_info and float_compare(supplier_info.price, line.price_unit, precision_digits=2) != 0: |
| 18 | + supplier_info.write({ |
| 19 | + 'min_qty': line.product_qty, |
| 20 | + 'price': line.price_unit, |
| 21 | + }) |
| 22 | + product.write({'standard_price': line.price_unit}) |
| 23 | +]]></field> |
| 24 | + </record> |
| 25 | + |
| 26 | + <record id="automate_sipplier_info_invoices" model="ir.actions.server"> |
| 27 | + <field name="name">Automate the supplier info cost Invoices</field> |
| 28 | + <field name="model_id" ref="account.model_account_move"/> |
| 29 | + <field name="base_automation_id" ref="base_automation_2"/> |
| 30 | + <field name="state">code</field> |
| 31 | + <field name="code"><![CDATA[ |
| 32 | +for line in record.invoice_line_ids: |
| 33 | + product = line.product_id |
| 34 | + if product.categ_id.x_automate_cost_update: |
| 35 | + supplier_info = env['product.supplierinfo'].search([ |
| 36 | + ('product_tmpl_id', '=', product.product_tmpl_id.id), |
| 37 | + ('partner_id', '=', record.partner_id.id) |
| 38 | + ], limit=1) |
| 39 | +
|
| 40 | + if supplier_info and float_compare(supplier_info.price, line.price_unit, precision_digits=2) != 0: |
| 41 | + supplier_info.write({ |
| 42 | + 'min_qty': line.quantity, |
| 43 | + 'price': line.price_unit, |
| 44 | + }) |
| 45 | + product.write({'standard_price': line.price_unit}) |
| 46 | +]]></field> |
| 47 | + </record> |
| 48 | +</odoo> |
0 commit comments