Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] *: no tracking for consumable product #31355

Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+24 −5
Diff settings


Just for now

@@ -311,6 +311,11 @@ def _onchange_uom_id(self):
if self.uom_id:
self.uom_po_id =

def _onchange_type(self):
# Do nothing but needed for inheritance
return {}

def create(self, vals_list):
''' Store the initial standard price in order to be able to retrieve the cost of a product template for a given date'''
@@ -148,10 +148,12 @@ def create_product_variant(self, product_template_attribute_value_ids):
def _onchange_type(self):
""" Force values to stay consistent with integrity constraints """
res = super(ProductTemplate, self)._onchange_type()
if self.type == 'consu':
if not self.invoice_policy:
self.invoice_policy = 'order'
self.service_type = 'manual'
return res

def get_import_templates(self):
@@ -14,9 +14,11 @@ class ProductTemplate(models.Model):

def _onchange_product_type(self):
def _onchange_type(self):
res = super(ProductTemplate, self)._onchange_type()
if self.type != 'service':
self.service_to_purchase = False
return res

def _onchange_expense_policy(self):
@@ -12,7 +12,8 @@ def _onchange_type(self):
""" We want to prevent storable product to be expensed, since it make no sense as when confirm
expenses, the product is already out of our stock.
super(ProductTemplate, self)._onchange_type()
res = super(ProductTemplate, self)._onchange_type()
if self.type == 'product':
self.expense_policy = 'no'
self.service_type = 'manual'
return res
@@ -88,12 +88,13 @@ def _onchange_service_tracking(self):

def _onchange_type(self):
super(ProductTemplate, self)._onchange_type()
res = super(ProductTemplate, self)._onchange_type()
if self.type == 'service':
self.invoice_policy = 'order'
self.service_type = 'timesheet'
elif self.type == 'consu' and self.service_policy == 'ordered_timesheet':
self.invoice_policy = 'order'
return res

class ProductProduct(models.Model):
@@ -566,6 +566,13 @@ def _compute_nbr_reordering_rules(self):
def onchange_tracking(self):
return self.mapped('product_variant_ids').onchange_tracking()

def _onchange_type(self):
res = super(ProductTemplate, self)._onchange_type()
if self.type == 'consu' and self.tracking != 'none':
self.tracking = 'none'
This conversation was marked as resolved by svs-odoo

This comment has been minimized.

Copy link

sle-odoo Feb 25, 2019


res = super
return res

return res

def write(self, vals):
if 'uom_id' in vals:
new_uom = self.env['uom.uom'].browse(vals['uom_id'])
@@ -16,7 +16,7 @@ class ProductionLot(models.Model):
ref = fields.Char('Internal Reference', help="Internal reference number in case it differs from the manufacturer's lot/serial number")
product_id = fields.Many2one(
'product.product', 'Product',
domain=[('type', 'in', ['product', 'consu'])], required=True)
domain=[('type', '=', 'product')], required=True)
product_uom_id = fields.Many2one(
'uom.uom', 'Unit of Measure',
related='product_id.uom_id', store=True, readonly=False)
@@ -111,7 +111,8 @@
<field name="sale_delay" class="oe_inline" style="vertical-align:baseline"/> days
<group string="Traceability" name="traceability" groups="stock.group_production_lot">
<group string="Traceability" name="traceability" groups="stock.group_production_lot"
attrs="{'invisible': [('type', '=', 'consu')]}">
<field name="tracking" widget="radio" attrs="{'invisible': [('type', 'in', ['service', 'digital'])]}"/>
<group string="Counterpart Locations" name="stock_property" groups="base.group_no_one">
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.