[IMP] nfu_sale_order_batch_packaging: add regeneration of batch products
This commit is contained in:
parent
ce6989e680
commit
391a24903d
13 changed files with 37 additions and 7 deletions
|
|
@ -36,6 +36,7 @@ Changelog
|
||||||
:0.0.1: Initial module.
|
:0.0.1: Initial module.
|
||||||
:1.0.0: rename to nfu_sale_order_batch_packaging
|
:1.0.0: rename to nfu_sale_order_batch_packaging
|
||||||
:1.1.0: Live
|
:1.1.0: Live
|
||||||
|
:1.2.0: Add regeneration action for batch products
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"author": "BAKEUP",
|
"author": "BAKEUP",
|
||||||
"website": "https://www.bakeup.org",
|
"website": "https://www.bakeup.org",
|
||||||
"category": "Sale",
|
"category": "Sale",
|
||||||
"version": "16.0.1.1.0",
|
"version": "16.0.1.2.0",
|
||||||
"depends": ["sale", "sale_order_batch"],
|
"depends": ["sale", "sale_order_batch"],
|
||||||
"data": [
|
"data": [
|
||||||
"views/sale_order_views.xml",
|
"views/sale_order_views.xml",
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
|
from . import sale_order_batch
|
||||||
from . import sale_order_line
|
from . import sale_order_line
|
||||||
from . import sale_order_batch_product
|
from . import sale_order_batch_product
|
||||||
|
|
|
||||||
11
nfu_sale_order_batch_packaging/models/sale_order_batch.py
Normal file
11
nfu_sale_order_batch_packaging/models/sale_order_batch.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
from odoo import models
|
||||||
|
|
||||||
|
|
||||||
|
class SaleOrderBatch(models.Model):
|
||||||
|
_inherit = "sale.order.batch"
|
||||||
|
|
||||||
|
def action_recompute_products(self):
|
||||||
|
for batch in self:
|
||||||
|
batch.product_ids.unlink()
|
||||||
|
for line in batch.sale_order_line_ids:
|
||||||
|
line._update_batch_product()
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
:0.0.1: Initial module.
|
:0.0.1: Initial module.
|
||||||
:1.0.0: rename to nfu_sale_order_batch_packaging
|
:1.0.0: rename to nfu_sale_order_batch_packaging
|
||||||
:1.1.0: Live
|
:1.1.0: Live
|
||||||
|
:1.2.0: Add regeneration action for batch products
|
||||||
|
|
@ -397,6 +397,8 @@ and adds a packaging default to sale order batch.</p>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.1.0:</th><td class="field-body">Live</td>
|
<tr class="field"><th class="field-name">1.1.0:</th><td class="field-body">Live</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="field"><th class="field-name">1.2.0:</th><td class="field-body">Add regeneration action for batch products</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,15 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
<record id="action_update_batch_products_binding" model="ir.actions.server">
|
||||||
|
<field name="name">Regenerate Products</field>
|
||||||
|
<field name="model_id" ref="model_sale_order_batch"/>
|
||||||
|
<field name="binding_model_id" ref="model_sale_order_batch"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">
|
||||||
|
for batch in records:
|
||||||
|
batch.action_recompute_products()
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
<record id="view_order_batch_form" model="ir.ui.view">
|
<record id="view_order_batch_form" model="ir.ui.view">
|
||||||
<field name="name">sale.order.batch.form.product.min_max_qty</field>
|
<field name="name">sale.order.batch.form.product.min_max_qty</field>
|
||||||
<field name="model">sale.order.batch</field>
|
<field name="model">sale.order.batch</field>
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ Changelog
|
||||||
|
|
||||||
:0.0.1: Initial module.
|
:0.0.1: Initial module.
|
||||||
:1.0.0: Add Multi Company ability
|
:1.0.0: Add Multi Company ability
|
||||||
|
:1.0.1: rename product creation methode
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"author": "BAKEUP",
|
"author": "BAKEUP",
|
||||||
"website": "https://www.bakeup.org",
|
"website": "https://www.bakeup.org",
|
||||||
"category": "Sale",
|
"category": "Sale",
|
||||||
"version": "16.0.1.0.0",
|
"version": "16.0.1.0.1",
|
||||||
"depends": ["sale", "product"],
|
"depends": ["sale", "product"],
|
||||||
"data": [
|
"data": [
|
||||||
"data/ir_sequence_data.xml",
|
"data/ir_sequence_data.xml",
|
||||||
|
|
|
||||||
|
|
@ -52,5 +52,5 @@ class SaleOrder(models.Model):
|
||||||
raise UserError(_(f"Sale Order not in State Draft or Sent: {', '.join(invalid_orders)}"))
|
raise UserError(_(f"Sale Order not in State Draft or Sent: {', '.join(invalid_orders)}"))
|
||||||
res = super().write(vals)
|
res = super().write(vals)
|
||||||
if "batch_id" in vals:
|
if "batch_id" in vals:
|
||||||
self.order_line._update_batch_products()
|
self.order_line._update_batch_product()
|
||||||
return res
|
return res
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ class SaleOrderLine(models.Model):
|
||||||
|
|
||||||
batch_id = fields.Many2one(related="order_id.batch_id")
|
batch_id = fields.Many2one(related="order_id.batch_id")
|
||||||
|
|
||||||
def _update_batch_products(self):
|
def _update_batch_product(self):
|
||||||
for order_line in self:
|
for order_line in self:
|
||||||
batch_id = order_line.order_id.batch_id
|
batch_id = order_line.order_id.batch_id
|
||||||
if batch_id:
|
if batch_id:
|
||||||
|
|
@ -19,5 +19,5 @@ class SaleOrderLine(models.Model):
|
||||||
@api.model_create_multi
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
res = super().create(vals_list)
|
res = super().create(vals_list)
|
||||||
res._update_batch_products()
|
res._update_batch_product()
|
||||||
return res
|
return res
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
:0.0.1: Initial module.
|
:0.0.1: Initial module.
|
||||||
:1.0.0: Add Multi Company ability
|
:1.0.0: Add Multi Company ability
|
||||||
|
:1.0.1: rename product creation methode
|
||||||
|
|
@ -396,6 +396,8 @@ anymore as log as they are part of a batch. Only Sale Orders in state Qutotation
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.0.0:</th><td class="field-body">Add Multi Company ability</td>
|
<tr class="field"><th class="field-name">1.0.0:</th><td class="field-body">Add Multi Company ability</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="field"><th class="field-name">1.0.1:</th><td class="field-body">rename product creation methode</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue