diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-09-26 15:06:52 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-09-26 15:06:52 +0700 |
| commit | 01f308991afffaff5eda1b758dbb98d0f3ba8396 (patch) | |
| tree | 42a996176f451a3feb4bbfb2a7f8cad9849dd85e | |
| parent | bd8a83a76cea6ef2466c250226f7c95c38b3024c (diff) | |
User can't create data cab on form input, add multi update data sale order to update state and invoice_status
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 23 | ||||
| -rw-r--r-- | indoteknik_custom/views/invoice_reklas.xml | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 18 |
4 files changed, 43 insertions, 2 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index daf8d269..08f38afe 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -324,7 +324,7 @@ class PurchaseOrder(models.Model): 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), + ('id', '=', line.so_line_id.id), ('order_id', '=', line.order_id.sale_order_id.id) ], limit=1, order='price_reduce_taxexcl') for so_line in sale_order_line: diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 2d8d97bd..13f4745d 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -80,6 +80,29 @@ class SaleOrder(models.Model): estimated_arrival_days = fields.Integer('Estimated Arrival Days', default=0) email = fields.Char(string='Email') + @api.model + def action_multi_update_state(self): + order_ids = self.env.context.get('active_ids', []) + sale_order = self.search([('id', 'in', order_ids)]) + for sale in sale_order: + sale.update({ + 'state': 'cancel', + }) + + if sale.state == 'cancel': + sale.update({ + 'approval_status': False, + }) + + @api.model + def action_multi_update_invoice_status(self): + order_ids = self.env.context.get('active_ids', []) + sale_order = self.search([('id', 'in', order_ids)]) + for sale in sale_order: + sale.update({ + 'invoice_status': 'invoiced', + }) + def _compute_purchase_total(self): for order in self: total = 0 diff --git a/indoteknik_custom/views/invoice_reklas.xml b/indoteknik_custom/views/invoice_reklas.xml index e807dca5..a29139ad 100644 --- a/indoteknik_custom/views/invoice_reklas.xml +++ b/indoteknik_custom/views/invoice_reklas.xml @@ -10,7 +10,7 @@ </p> <group> <field name="reklas_type"/> - <field name="reklas_id"/> + <field name="reklas_id" options="{'no_create': True}"/> <field name="pay_amt"/> </group> <footer> diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 1e83d4b4..69771844 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -169,5 +169,23 @@ </field> </field> </record> + + <record id="sale_order_multi_update_ir_actions_server" model="ir.actions.server"> + <field name="name">Mark As Cancel</field> + <field name="model_id" ref="sale.model_sale_order"/> + <field name="binding_model_id" ref="sale.model_sale_order"/> + <field name="binding_view_types">form,list</field> + <field name="state">code</field> + <field name="code">model.action_multi_update_state()</field> + </record> + + <record id="sale_order_update_multi_actions_server" model="ir.actions.server"> + <field name="name">Mark As Completed</field> + <field name="model_id" ref="sale.model_sale_order"/> + <field name="binding_model_id" ref="sale.model_sale_order"/> + <field name="binding_view_types">form,list</field> + <field name="state">code</field> + <field name="code">model.action_multi_update_invoice_status()</field> + </record> </data> </odoo>
\ No newline at end of file |
