[IMP] stock: better use of scrap form

When creating a scrap, the `scrap_qty` is fixed to 1 in case the product
is tracked by serial number.
Also, pass the company and product ids in case user creates a new lot
number from the scrap form.
This commit is contained in:
svs-odoo
2019-09-05 10:18:06 +00:00
parent f04141093c
commit 863afa2ab0
2 changed files with 7 additions and 2 deletions
+2
View File
@@ -66,6 +66,8 @@ class StockScrap(models.Model):
@api.onchange('product_id')
def _onchange_product_id(self):
if self.product_id:
if self.tracking == 'serial':
self.scrap_qty = 1
self.product_uom_id = self.product_id.uom_id.id
# Check if we can get a more precise location instead of
# the default location (a location corresponding to where the
+5 -2
View File
@@ -157,7 +157,8 @@
<field name="product_id" options="{'no_create': True}" domain="[('id', 'in', context.get('product_ids', []))]"/>
<label for="scrap_qty"/>
<div class="o_row">
<field name="scrap_qty"/>
<field name="scrap_qty"
attrs="{'readonly': [('tracking', '=', 'serial')]}"/>
<field name="product_uom_category_id" invisible="1"/>
<field name="product_uom_id" groups="uom.group_uom"/>
</div>
@@ -165,7 +166,9 @@
<group>
<field name="picking_id" invisible="1"/>
<field name="tracking" invisible="1"/>
<field name="lot_id" attrs="{'invisible': ['|',('product_id', '=', False),('tracking', '=', 'none')], 'required': [('tracking', '!=', 'none')]}" groups="stock.group_production_lot"/>
<field name="lot_id" groups="stock.group_production_lot"
context="{'default_company_id': company_id, 'default_product_id': product_id}"
attrs="{'invisible': ['|',('product_id', '=', False),('tracking', '=', 'none')], 'required': [('tracking', '!=', 'none')]}"/>
<field name="package_id" groups="stock.group_tracking_lot"/>
<field name="owner_id" groups="stock.group_tracking_owner"/>
<field name="company_id" invisible="1"/>