summaryrefslogtreecommitdiff
path: root/addons/stock
diff options
context:
space:
mode:
authorsvs-odoo <svs@odoo.com>2019-09-04 12:37:28 +0000
committersvs-odoo <svs@odoo.com>2019-09-05 10:18:06 +0000
commit863afa2ab0e1ce5d474e1cdaa84cc5651ebb8042 (patch)
tree4dac662af60725ffd40ae432e4efd0c27931d59b /addons/stock
parentf04141093c5aa824736fc2f6f5fe352d83fd5a74 (diff)
[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.
Diffstat (limited to 'addons/stock')
-rw-r--r--addons/stock/models/stock_scrap.py2
-rw-r--r--addons/stock/views/stock_scrap_views.xml7
2 files changed, 7 insertions, 2 deletions
diff --git a/addons/stock/models/stock_scrap.py b/addons/stock/models/stock_scrap.py
index 4bf89e24a68..2e7d6eb021e 100644
--- a/addons/stock/models/stock_scrap.py
+++ b/addons/stock/models/stock_scrap.py
@@ -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
diff --git a/addons/stock/views/stock_scrap_views.xml b/addons/stock/views/stock_scrap_views.xml
index 311149dc43c..6c88a0988ea 100644
--- a/addons/stock/views/stock_scrap_views.xml
+++ b/addons/stock/views/stock_scrap_views.xml
@@ -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"/>