feat: Refactor packaging fields to use product.uom for quantity calculations and remove group restrictions.
This commit is contained in:
parent
49db20c6d4
commit
c305b0f113
@ -1,6 +1,6 @@
|
||||
{
|
||||
'name': 'MRP Packaging Quantity',
|
||||
'version': '18.0.1.0.0',
|
||||
'version': '19.0.1.0.1',
|
||||
'category': 'Manufacturing',
|
||||
'summary': 'Add packaging fields to Manufacturing Orders',
|
||||
'description': """
|
||||
@ -8,7 +8,7 @@
|
||||
It allows users to define the quantity to produce based on the selected packaging and its quantity.
|
||||
""",
|
||||
'author': 'Suherdy Yacob',
|
||||
'depends': ['mrp'],
|
||||
'depends': ['mrp', 'product'],
|
||||
'data': [
|
||||
'views/mrp_production_views.xml',
|
||||
],
|
||||
|
||||
@ -3,10 +3,10 @@ from odoo import api, fields, models
|
||||
class MrpProduction(models.Model):
|
||||
_inherit = 'mrp.production'
|
||||
|
||||
packaging_id = fields.Many2one('product.packaging', string='Packaging', domain="[('product_id', '=', product_id)]", check_company=True)
|
||||
packaging_id = fields.Many2one('product.uom', string='Packaging', domain="[('product_id', '=', product_id)]", check_company=True)
|
||||
packaging_qty = fields.Float('Quantity Packaging', default=0.0, digits='Product Unit of Measure')
|
||||
|
||||
@api.onchange('packaging_id', 'packaging_qty')
|
||||
def _onchange_packaging_qty(self):
|
||||
if self.packaging_id and self.packaging_qty:
|
||||
self.product_qty = self.packaging_id.qty * self.packaging_qty
|
||||
self.product_qty = self.packaging_id.uom_id._compute_quantity(self.packaging_qty, self.product_uom_id)
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='product_qty']/.." position="after">
|
||||
<field name="packaging_id" groups="product.group_stock_packaging"/>
|
||||
<field name="packaging_qty" groups="product.group_stock_packaging"/>
|
||||
<field name="packaging_id"/>
|
||||
<field name="packaging_qty"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user