[IMP] sale: Make some field precomputed

This commit is contained in:
Yannick Tivisse
2021-12-02 12:12:03 +01:00
parent 48401aa9a0
commit 232d66069a
14 changed files with 80 additions and 68 deletions
+2 -2
View File
@@ -61,11 +61,11 @@ class SaleOrderLine(models.Model):
event_id = fields.Many2one(
'event.event', string='Event',
compute="_compute_event_id", store=True, readonly=False, pre_compute=True,
compute="_compute_event_id", store=True, readonly=False, precompute=True,
help="Choose an event and it will automatically create a registration for this event.")
event_ticket_id = fields.Many2one(
'event.event.ticket', string='Event Ticket',
compute="_compute_event_ticket_id", store=True, readonly=False, pre_compute=True,
compute="_compute_event_ticket_id", store=True, readonly=False, precompute=True,
help="Choose an event ticket and it will automatically create a registration for this event ticket.")
event_ok = fields.Boolean(compute='_compute_event_ok')
+4 -3
View File
@@ -39,11 +39,12 @@ class AccountAnalyticLine(models.Model):
return []
task_id = fields.Many2one(
'project.task', 'Task', compute='_compute_task_id', store=True, readonly=False, index=True,
'project.task', 'Task', index=True,
compute='_compute_task_id', store=True, readonly=False, precompute=True,
domain="[('company_id', '=', company_id), ('project_id.allow_timesheets', '=', True), ('project_id', '=?', project_id)]")
project_id = fields.Many2one(
'project.project', 'Project', compute='_compute_project_id', store=True, readonly=False,
domain=_domain_project_id)
'project.project', 'Project', domain=_domain_project_id,
compute='_compute_project_id', store=True, readonly=False, precompute=True)
user_id = fields.Many2one(compute='_compute_user_id', store=True, readonly=False)
employee_id = fields.Many2one('hr.employee', "Employee", domain=_domain_employee_id)
department_id = fields.Many2one('hr.department', "Department", compute='_compute_department_id', store=True, compute_sudo=True)
+4 -4
View File
@@ -936,8 +936,8 @@ class Task(models.Model):
index=True,
copy=False,
readonly=True)
project_id = fields.Many2one('project.project', string='Project',
compute='_compute_project_id', recursive=True, store=True, readonly=False,
project_id = fields.Many2one('project.project', string='Project', recursive=True,
compute='_compute_project_id', store=True, readonly=False, precompute=True,
index=True, tracking=True, check_company=True, change_default=True)
# Defines in which project the task will be displayed / taken into account in statistics.
# Example: 1 task A with 1 subtask B in project P
@@ -967,8 +967,8 @@ class Task(models.Model):
search='_search_personal_stage_type_id',
help="The current user's personal task stage.")
partner_id = fields.Many2one('res.partner',
string='Customer',
compute='_compute_partner_id', recursive=True, store=True, readonly=False, tracking=True,
string='Customer', recursive=True, tracking=True,
compute='_compute_partner_id', store=True, readonly=False, precompute=True,
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]")
partner_is_company = fields.Boolean(related='partner_id.is_company', readonly=True)
commercial_partner_id = fields.Many2one(related='partner_id.commercial_partner_id')
+1 -1
View File
@@ -32,7 +32,7 @@ class AccountMove(models.Model):
source_id = fields.Many2one(ondelete='set null')
fiscal_position_id = fields.Many2one(
compute='_compute_fiscal_position_id', store=True, pre_compute=True)
compute='_compute_fiscal_position_id', store=True)
@api.depends('partner_shipping_id', 'company_id')
+11 -11
View File
@@ -167,32 +167,32 @@ class SaleOrder(models.Model):
user_id = fields.Many2one(
'res.users', string='Salesperson', index=True, tracking=2,
compute='_compute_user_id', store=True, readonly=False, pre_compute=True,
compute='_compute_user_id', store=True, readonly=False, precompute=True,
domain=lambda self: [('groups_id', 'in', self.env.ref('sales_team.group_sale_salesman').id)])
partner_id = fields.Many2one(
'res.partner', string='Customer', readonly=False, pre_compute=True,
'res.partner', string='Customer', readonly=False,
states={'sale': [('readonly', True)], 'done': [('readonly', True)], 'cancel': [('readonly', True)]},
required=True, change_default=True, index=True, tracking=1,
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",)
partner_invoice_id = fields.Many2one(
'res.partner', string='Invoice Address', required=True,
compute='_compute_partner_invoice_id', store=True, readonly=False, pre_compute=True,
compute='_compute_partner_invoice_id', store=True, readonly=False, precompute=True,
states={'done': [('readonly', True)], 'cancel': [('readonly', True)]},
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",)
partner_shipping_id = fields.Many2one(
'res.partner', string='Delivery Address', required=True,
compute='_compute_partner_shipping_id', store=True, readonly=False, pre_compute=True,
compute='_compute_partner_shipping_id', store=True, readonly=False, precompute=True,
states={'done': [('readonly', True)], 'cancel': [('readonly', True)]},
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",)
pricelist_id = fields.Many2one(
'product.pricelist', string='Pricelist', required=False, check_company=True, # Unrequired company
compute='_compute_pricelist_id', store=True, pre_compute=True, readonly=False,
compute='_compute_pricelist_id', store=True, precompute=True, readonly=False,
states={'sale': [('readonly', True)], 'done': [('readonly', True)], 'cancel': [('readonly', True)]},
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", tracking=1,
help="If you change the pricelist, only newly added lines will be affected.")
currency_id = fields.Many2one(
related='pricelist_id.currency_id', depends=["pricelist_id"], store=True, pre_compute=True, ondelete="restrict")
related='pricelist_id.currency_id', depends=["pricelist_id"], store=True, precompute=True, ondelete="restrict")
analytic_account_id = fields.Many2one(
'account.analytic.account', 'Analytic Account',
readonly=True, copy=False, check_company=True, # Unrequired company
@@ -213,7 +213,7 @@ class SaleOrder(models.Model):
note = fields.Html(
'Terms and conditions',
compute='_compute_note', store=True, readonly=False, pre_compute=True)
compute='_compute_note', store=True, readonly=False, precompute=True)
terms_type = fields.Selection(related='company_id.terms_type')
amount_untaxed = fields.Monetary(string='Untaxed Amount', store=True, compute='_amount_all', tracking=5)
@@ -224,12 +224,12 @@ class SaleOrder(models.Model):
payment_term_id = fields.Many2one(
'account.payment.term', string='Payment Terms', check_company=True, # Unrequired company
compute='_compute_payment_term_id', store=True, readonly=False,
compute='_compute_payment_term_id', store=True, readonly=False, precompute=True,
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",)
fiscal_position_id = fields.Many2one(
'account.fiscal.position', string='Fiscal Position',
domain="[('company_id', '=', company_id)]", check_company=True,
compute='_compute_fiscal_position_id', store=True, readonly=False,
compute='_compute_fiscal_position_id', store=True, readonly=False, precompute=True,
help="Fiscal positions are used to adapt taxes and accounts for particular customers or sales orders/invoices."
"The default value comes from the customer.")
tax_country_id = fields.Many2one(
@@ -240,7 +240,7 @@ class SaleOrder(models.Model):
team_id = fields.Many2one(
'crm.team', 'Sales Team',
ondelete="set null", tracking=True,
compute='_compute_team_id', store=True, readonly=False, pre_compute=True,
compute='_compute_team_id', store=True, readonly=False, precompute=True,
change_default=True, check_company=True, # Unrequired company
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]")
@@ -266,7 +266,7 @@ class SaleOrder(models.Model):
string='Authorized Transactions', copy=False)
show_update_pricelist = fields.Boolean(
string='Has Pricelist Changed',
compute='_compute_show_update_pricelist', store=True, readonly=True, pre_compute=True,
compute='_compute_show_update_pricelist', store=True, readonly=True, precompute=True,
help="Technical Field, True if the pricelist was changed;\n"
" this will then display a recomputation button")
tag_ids = fields.Many2many('crm.tag', 'sale_order_tag_rel', 'order_id', 'tag_id', string='Tags')
+32 -30
View File
@@ -212,7 +212,7 @@ class SaleOrderLine(models.Model):
order_id = fields.Many2one('sale.order', string='Order Reference', required=True, ondelete='cascade', index=True, copy=False)
name = fields.Text(
string='Description', required=True,
compute='_compute_name', store=True, readonly=False, pre_compute=True)
compute='_compute_name', store=True, readonly=False, precompute=True)
sequence = fields.Integer(string='Sequence', default=10)
invoice_lines = fields.Many2many('account.move.line', 'sale_order_line_invoice_rel', 'order_line_id', 'invoice_line_id', string='Invoice Lines', copy=False)
@@ -221,28 +221,30 @@ class SaleOrderLine(models.Model):
('invoiced', 'Fully Invoiced'),
('to invoice', 'To Invoice'),
('no', 'Nothing to Invoice')
], string='Invoice Status', compute='_compute_invoice_status', store=True, pre_compute=True)
], string='Invoice Status', compute='_compute_invoice_status', store=True, precompute=True)
price_unit = fields.Float(
'Unit Price', required=True, digits='Product Price',
compute='_compute_price_unit', store=True, readonly=False, pre_compute=True)
price_subtotal = fields.Monetary(compute='_compute_amount', string='Subtotal', store=True)
price_tax = fields.Float(compute='_compute_amount', string='Total Tax', store=True)
price_total = fields.Monetary(compute='_compute_amount', string='Total', store=True)
compute='_compute_price_unit', store=True, readonly=False, precompute=True)
price_reduce = fields.Float(
string='Price Reduce', digits='Product Price',
compute='_compute_price_reduce', store=True, pre_compute=True)
compute='_compute_price_reduce', store=True, precompute=True)
price_subtotal = fields.Monetary(compute='_compute_amount', string='Subtotal', store=True, precompute=True)
price_tax = fields.Float(compute='_compute_amount', string='Total Tax', store=True, precompute=True)
price_total = fields.Monetary(compute='_compute_amount', string='Total', store=True, precompute=True)
price_reduce_taxinc = fields.Monetary(
compute='_compute_price_reduce_taxinc', string='Price Reduce Tax inc', store=True, precompute=True)
price_reduce_taxexcl = fields.Monetary(
compute='_compute_price_reduce_taxexcl', string='Price Reduce Tax excl', store=True, precompute=True)
tax_id = fields.Many2many(
'account.tax', string='Taxes',
compute='_compute_tax_id', store=True, readonly=False, pre_compute=True,
compute='_compute_tax_id', store=True, readonly=False, precompute=True,
domain=['|', ('active', '=', False), ('active', '=', True)])
price_reduce_taxinc = fields.Monetary(compute='_compute_price_reduce_taxinc', string='Price Reduce Tax inc', store=True)
price_reduce_taxexcl = fields.Monetary(compute='_compute_price_reduce_taxexcl', string='Price Reduce Tax excl', store=True)
discount = fields.Float(
string='Discount (%)', digits='Discount',
compute='_compute_discount', store=True, readonly=False, pre_compute=True)
compute='_compute_discount', store=True, readonly=False, precompute=True)
product_id = fields.Many2one(
'product.product', string='Product', domain="[('sale_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', company_id)]",
@@ -253,28 +255,28 @@ class SaleOrderLine(models.Model):
product_updatable = fields.Boolean(compute='_compute_product_updatable', string='Can Edit Product')
product_uom_qty = fields.Float(
string='Quantity', digits='Product Unit of Measure', required=True,
compute='_compute_product_uom_qty', store=True, readonly=False, pre_compute=True)
compute='_compute_product_uom_qty', store=True, readonly=False, precompute=True)
product_uom = fields.Many2one(
'uom.uom', string='Unit of Measure',
compute='_compute_product_uom', store=True, readonly=False, pre_compute=True,
compute='_compute_product_uom', store=True, readonly=False, precompute=True,
domain="[('category_id', '=', product_uom_category_id)]", ondelete="restrict")
product_uom_category_id = fields.Many2one(related='product_id.uom_id.category_id')
product_uom_readonly = fields.Boolean(compute='_compute_product_uom_readonly')
product_custom_attribute_value_ids = fields.One2many(
'product.attribute.custom.value', 'sale_order_line_id',
string="Custom Values", copy=True,
compute='_compute_custom_attribute_values', store=True, readonly=False, pre_compute=True)
compute='_compute_custom_attribute_values', store=True, readonly=False, precompute=True)
# M2M holding the values of product.attribute with create_variant field set to 'no_variant'
# It allows keeping track of the extra_price associated to those attribute values and add them to the SO line description
product_no_variant_attribute_value_ids = fields.Many2many(
'product.template.attribute.value', string="Extra Values", ondelete='restrict',
compute='_compute_no_variant_attribute_values', store=True, readonly=False, pre_compute=True)
compute='_compute_no_variant_attribute_values', store=True, readonly=False, precompute=True)
qty_delivered_method = fields.Selection(
[('manual', 'Manual'),
('analytic', 'Analytic From Expenses')], string="Method to update delivered qty",
compute='_compute_qty_delivered_method', store=True, pre_compute=True,
compute='_compute_qty_delivered_method', store=True, precompute=True,
help="According to product configuration, the delivered quantity can be automatically computed by mechanism :\n"
" - Manual: the quantity is set manually on the line\n"
" - Analytic From expenses: the quantity is the quantity sum from posted expenses\n"
@@ -282,21 +284,21 @@ class SaleOrderLine(models.Model):
" - Stock Moves: the quantity comes from confirmed pickings\n")
qty_delivered = fields.Float(
'Delivered Quantity', copy=False,
compute='_compute_qty_delivered', store=True, readonly=False, pre_compute=True,
compute='_compute_qty_delivered', store=True, readonly=False, precompute=True,
digits='Product Unit of Measure')
qty_to_invoice = fields.Float(
compute='_compute_qty_to_invoice', string='To Invoice Quantity', store=True, pre_compute=True,
compute='_compute_qty_to_invoice', string='To Invoice Quantity', store=True, precompute=True,
digits='Product Unit of Measure')
qty_invoiced = fields.Float(
compute='_compute_qty_invoiced', string='Invoiced Quantity', store=True, pre_compute=True,
compute='_compute_qty_invoiced', string='Invoiced Quantity', store=True, precompute=True,
digits='Product Unit of Measure')
untaxed_amount_invoiced = fields.Monetary(
"Untaxed Invoiced Amount",
compute='_compute_untaxed_amount_invoiced', store=True, pre_compute=True)
compute='_compute_untaxed_amount_invoiced', store=True, precompute=True)
untaxed_amount_to_invoice = fields.Monetary(
"Untaxed Amount To Invoice",
compute='_compute_untaxed_amount_to_invoice', store=True, pre_compute=True)
compute='_compute_untaxed_amount_to_invoice', store=True, precompute=True)
analytic_tag_ids = fields.Many2many(
'account.analytic.tag', string='Analytic Tags',
@@ -310,16 +312,16 @@ class SaleOrderLine(models.Model):
# Related stored fields from the order
currency_id = fields.Many2one(
related='order_id.currency_id', depends=['order_id.currency_id'],
store=True, string='Currency', pre_compute=True)
company_id = fields.Many2one(related='order_id.company_id', string='Company', store=True, index=True, pre_compute=True)
order_partner_id = fields.Many2one(related='order_id.partner_id', store=True, string='Customer', pre_compute=True)
salesman_id = fields.Many2one(related='order_id.user_id', store=True, string='Salesperson', pre_compute=True)
store=True, string='Currency', precompute=True)
company_id = fields.Many2one(related='order_id.company_id', string='Company', store=True, index=True, precompute=True)
order_partner_id = fields.Many2one(related='order_id.partner_id', store=True, string='Customer', precompute=True)
salesman_id = fields.Many2one(related='order_id.user_id', store=True, string='Salesperson', precompute=True)
state = fields.Selection(
related='order_id.state', string='Order Status', copy=False, store=True, pre_compute=True)
related='order_id.state', string='Order Status', copy=False, store=True, precompute=True)
customer_lead = fields.Float(
'Lead Time', required=True,
compute="_compute_customer_lead", store=True, readonly=False, pre_compute=True,
compute="_compute_customer_lead", store=True, readonly=False, precompute=True,
help="Number of days between the order confirmation and the shipping of the products to the customer")
display_type = fields.Selection([
@@ -328,12 +330,12 @@ class SaleOrderLine(models.Model):
product_packaging_id = fields.Many2one(
'product.packaging', string='Packaging',
compute='_compute_product_packaging_id', store=True, readonly=False, pre_compute=True,
compute='_compute_product_packaging_id', store=True, readonly=False, precompute=True,
domain="[('sales', '=', True), ('product_id','=',product_id)]",
check_company=True)
product_packaging_qty = fields.Float(
'Packaging Quantity',
compute='_compute_product_packaging_qty', store=True, readonly=False, pre_compute=True)
compute='_compute_product_packaging_qty', store=True, readonly=False, precompute=True)
# This computed default is necessary
# because the ORM doesn't provide a way to remove a field default on inheritance
+3 -3
View File
@@ -8,12 +8,12 @@ class SaleOrderLine(models.Model):
margin = fields.Float(
"Margin", compute='_compute_margin',
digits='Product Price', store=True, groups="base.group_user")
digits='Product Price', store=True, groups="base.group_user", precompute=True)
margin_percent = fields.Float(
"Margin (%)", compute='_compute_margin', store=True, groups="base.group_user")
"Margin (%)", compute='_compute_margin', store=True, groups="base.group_user", precompute=True)
purchase_price = fields.Float(
string='Cost', compute="_compute_purchase_price",
digits='Product Price', store=True, readonly=False,
digits='Product Price', store=True, readonly=False, precompute=True,
groups="base.group_user")
@api.depends('product_id', 'company_id', 'currency_id', 'product_uom')
+6 -4
View File
@@ -12,7 +12,7 @@ class Project(models.Model):
sale_line_id = fields.Many2one(
'sale.order.line', 'Sales Order Item', copy=False,
compute="_compute_sale_line_id", store=True, readonly=False, index=True,
compute="_compute_sale_line_id", store=True, readonly=False, index=True, precompute=True,
domain="[('is_service', '=', True), ('is_expense', '=', False), ('state', 'in', ['sale', 'done']), ('order_partner_id', '=?', partner_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]",
help="Sales order item to which the project is linked. Link the timesheet entry to the sales order item defined on the project. "
"Only applies on tasks without sale order item defined, and if the employee is not in the 'Employee/Sales Order Item Mapping' of the project.")
@@ -139,8 +139,10 @@ class ProjectTask(models.Model):
sale_order_id = fields.Many2one('sale.order', 'Sales Order', compute='_compute_sale_order_id', store=True, help="Sales order to which the task is linked.")
sale_line_id = fields.Many2one(
'sale.order.line', 'Sales Order Item', domain="[('company_id', '=', company_id), ('is_service', '=', True), ('order_partner_id', 'child_of', commercial_partner_id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done'])]",
compute='_compute_sale_line', recursive=True, store=True, readonly=False, copy=False, tracking=True, index=True,
'sale.order.line', 'Sales Order Item',
copy=False, tracking=True, index=True, recursive=True,
compute='_compute_sale_line', store=True, readonly=False, precompute=True,
domain="[('company_id', '=', company_id), ('is_service', '=', True), ('order_partner_id', 'child_of', commercial_partner_id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done'])]",
help="Sales Order Item to which the time spent on this task will be added, in order to be invoiced to your customer.")
project_sale_order_id = fields.Many2one('sale.order', string="Project's sale order", related='project_id.sale_order_id')
invoice_count = fields.Integer("Number of invoices", related='sale_order_id.invoice_count')
@@ -164,7 +166,7 @@ class ProjectTask(models.Model):
task.partner_id = sale_order_id.partner_id
task.sale_order_id = sale_order_id
@api.depends('commercial_partner_id', 'sale_line_id.order_partner_id.commercial_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id')
@api.depends('commercial_partner_id', 'sale_line_id.order_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id')
def _compute_sale_line(self):
for task in self:
if not task.sale_line_id:
+2 -2
View File
@@ -29,7 +29,7 @@ class SaleOrder(models.Model):
"product lead time. Otherwise, it will be based on the shortest.")
warehouse_id = fields.Many2one(
'stock.warehouse', string='Warehouse', required=True,
compute='_compute_warehouse_id', store=True, readonly=False, pre_compute=True,
compute='_compute_warehouse_id', store=True, readonly=False, precompute=True,
states={'sale': [('readonly', True)], 'done': [('readonly', False)], 'cancel': [('readonly', False)]},
check_company=True)
picking_ids = fields.One2many('stock.picking', 'sale_id', string='Transfers')
@@ -268,7 +268,7 @@ class SaleOrderLine(models.Model):
is_mto = fields.Boolean(compute='_compute_is_mto')
display_qty_widget = fields.Boolean(compute='_compute_qty_to_deliver')
customer_lead = fields.Float(
compute='_compute_customer_lead', store=True, readonly=False, pre_compute=True,
compute='_compute_customer_lead', store=True, readonly=False, precompute=True,
inverse='_inverse_customer_lead')
@api.depends('product_type', 'product_uom_qty', 'qty_delivered', 'state', 'move_ids', 'product_uom')
+3 -1
View File
@@ -25,7 +25,9 @@ class AccountAnalyticLine(models.Model):
compute='_compute_timesheet_invoice_type', compute_sudo=True, store=True, readonly=True)
commercial_partner_id = fields.Many2one('res.partner', compute="_compute_commercial_partner")
timesheet_invoice_id = fields.Many2one('account.move', string="Invoice", readonly=True, copy=False, help="Invoice created from the timesheet")
so_line = fields.Many2one(compute="_compute_so_line", store=True, readonly=False, domain="[('is_service', '=', True), ('is_expense', '=', False), ('state', 'in', ['sale', 'done']), ('order_partner_id', 'child_of', commercial_partner_id)]")
so_line = fields.Many2one(
compute="_compute_so_line", store=True, readonly=False, precompute=True,
domain="[('is_service', '=', True), ('is_expense', '=', False), ('state', 'in', ['sale', 'done']), ('order_partner_id', 'child_of', commercial_partner_id)]")
# we needed to store it only in order to be able to groupby in the portal
order_id = fields.Many2one(related='so_line.order_id', store=True, readonly=False)
is_so_line_edited = fields.Boolean("Is Sales Order Item Manually Edited")
+3 -2
View File
@@ -53,7 +53,8 @@ class Project(models.Model):
compute="_compute_timesheet_product_id", store=True, readonly=False,
default=_default_timesheet_product_id)
warning_employee_rate = fields.Boolean(compute='_compute_warning_employee_rate')
partner_id = fields.Many2one(compute='_compute_partner_id', store=True, readonly=False)
partner_id = fields.Many2one(
compute='_compute_partner_id', store=True, readonly=False, precompute=True)
@api.depends('sale_line_id', 'sale_line_employee_ids', 'allow_billable')
def _compute_pricing_type(self):
@@ -482,7 +483,7 @@ class ProjectTask(models.Model):
super(ProjectTask, billable_tasks)._compute_sale_order_id()
(self - billable_tasks).sale_order_id = False
@api.depends('commercial_partner_id', 'sale_line_id.order_partner_id.commercial_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id', 'allow_billable')
@api.depends('commercial_partner_id', 'sale_line_id.order_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id', 'allow_billable')
def _compute_sale_line(self):
billable_tasks = self.filtered('allow_billable')
(self - billable_tasks).update({'sale_line_id': False})
@@ -10,7 +10,9 @@ class ProjectProductEmployeeMap(models.Model):
project_id = fields.Many2one('project.project', "Project", required=True)
employee_id = fields.Many2one('hr.employee', "Employee", required=True)
sale_line_id = fields.Many2one('sale.order.line', "Sales Order Item", compute="_compute_sale_line_id", store=True, readonly=False,
sale_line_id = fields.Many2one(
'sale.order.line', "Sales Order Item",
compute="_compute_sale_line_id", store=True, readonly=False, precompute=True,
domain="""[
('is_service', '=', True),
('is_expense', '=', False),
+2 -1
View File
@@ -116,7 +116,8 @@ class StockMove(models.Model):
"The other possibility allows you to directly create a procurement on the source location (and thus ignore "
"its current stock) to gather products. If we want to chain moves and have this one to wait for the previous, "
"this second option should be chosen.")
scrapped = fields.Boolean('Scrapped', related='location_dest_id.scrap_location', readonly=True, store=True)
scrapped = fields.Boolean(
'Scrapped', related='location_dest_id.scrap_location', readonly=True, store=True, precompute=True)
scrap_ids = fields.One2many('stock.scrap', 'move_id')
group_id = fields.Many2one('procurement.group', 'Procurement Group', default=_default_group_id)
rule_id = fields.Many2one(
+4 -3
View File
@@ -224,9 +224,10 @@ class Partner(models.Model):
contact_address = fields.Char(compute='_compute_contact_address', string='Complete Address')
# technical field used for managing commercial fields
commercial_partner_id = fields.Many2one('res.partner', string='Commercial Entity',
compute='_compute_commercial_partner', recursive=True,
store=True, index=True)
commercial_partner_id = fields.Many2one(
'res.partner', string='Commercial Entity',
compute='_compute_commercial_partner', store=True,
recursive=True, index=True)
commercial_company_name = fields.Char('Company Name Entity', compute='_compute_commercial_company_name',
store=True)
company_name = fields.Char('Company Name')