[FIX] account,*: preserve deactivated taxes
By default, when reading a m2m field, entries that are deactivated in the destination table are not included. This behavior is desirable in some cases (e.g. for "tags" or "categories", but not for entries that significantly impact other field values in the parent record, such as taxes. The problem is rather obvious: when displaying a paid invoice that used taxes that are now deactivated, the taxes are hidden while they still affect the computed amount. And after cancelling + resetting to draft, the tax is not taken into account anymore, while still being linked. Forcing the field-level (python) domain to include both active and inactive entries solves the problem: - when reading, displaying and recomputing values, deactivated taxes will be included. - when trying to pick a tax, deactivated entries will still be ignored, as expected. This commit applies the technique to all m2m fields that refer to taxes. Fixes #12066 opw-677751
This commit is contained in:
parent
270b2d0a78
commit
cd3f52ba10
|
@ -1283,7 +1283,7 @@ class account_invoice_line(models.Model):
|
|||
default=0.0)
|
||||
invoice_line_tax_id = fields.Many2many('account.tax',
|
||||
'account_invoice_line_tax', 'invoice_line_id', 'tax_id',
|
||||
string='Taxes', domain=[('parent_id', '=', False)])
|
||||
string='Taxes', domain=[('parent_id', '=', False), '|', ('active', '=', False), ('active', '=', True)])
|
||||
account_analytic_id = fields.Many2one('account.analytic.account',
|
||||
string='Analytic Account')
|
||||
company_id = fields.Many2one('res.company', string='Company',
|
||||
|
|
|
@ -578,7 +578,8 @@ class mrp_repair_line(osv.osv, ProductChangeMixin):
|
|||
'invoiced': fields.boolean('Invoiced', readonly=True, copy=False),
|
||||
'price_unit': fields.float('Unit Price', required=True, digits_compute=dp.get_precision('Product Price')),
|
||||
'price_subtotal': fields.function(_amount_line, string='Subtotal', digits_compute=dp.get_precision('Account')),
|
||||
'tax_id': fields.many2many('account.tax', 'repair_operation_line_tax', 'repair_operation_line_id', 'tax_id', 'Taxes'),
|
||||
'tax_id': fields.many2many('account.tax', 'repair_operation_line_tax', 'repair_operation_line_id', 'tax_id', 'Taxes',
|
||||
domain=['|', ('active', '=', False), ('active', '=', True)]),
|
||||
'product_uom_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True),
|
||||
'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True),
|
||||
'invoice_line_id': fields.many2one('account.invoice.line', 'Invoice Line', readonly=True, copy=False),
|
||||
|
@ -672,7 +673,8 @@ class mrp_repair_fee(osv.osv, ProductChangeMixin):
|
|||
'price_unit': fields.float('Unit Price', required=True),
|
||||
'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True),
|
||||
'price_subtotal': fields.function(_amount_line, string='Subtotal', digits_compute=dp.get_precision('Account')),
|
||||
'tax_id': fields.many2many('account.tax', 'repair_fee_line_tax', 'repair_fee_line_id', 'tax_id', 'Taxes'),
|
||||
'tax_id': fields.many2many('account.tax', 'repair_fee_line_tax', 'repair_fee_line_id', 'tax_id', 'Taxes',
|
||||
domain=['|', ('active', '=', False), ('active', '=', True)]),
|
||||
'invoice_line_id': fields.many2one('account.invoice.line', 'Invoice Line', readonly=True, copy=False),
|
||||
'to_invoice': fields.boolean('To Invoice'),
|
||||
'invoiced': fields.boolean('Invoiced', readonly=True, copy=False),
|
||||
|
|
|
@ -1098,7 +1098,7 @@ class purchase_order_line(osv.osv):
|
|||
'name': fields.text('Description', required=True),
|
||||
'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True),
|
||||
'date_planned': fields.date('Scheduled Date', required=True, select=True),
|
||||
'taxes_id': fields.many2many('account.tax', 'purchase_order_taxe', 'ord_id', 'tax_id', 'Taxes'),
|
||||
'taxes_id': fields.many2many('account.tax', 'purchase_order_taxe', 'ord_id', 'tax_id', 'Taxes', domain=['|', ('active', '=', False), ('active', '=', True)]),
|
||||
'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True),
|
||||
'product_id': fields.many2one('product.product', 'Product', domain=[('purchase_ok','=',True)], change_default=True),
|
||||
'move_ids': fields.one2many('stock.move', 'purchase_line_id', 'Reservation', readonly=True, ondelete='set null'),
|
||||
|
|
|
@ -923,7 +923,7 @@ class sale_order_line(osv.osv):
|
|||
'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price'), readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'price_subtotal': fields.function(_amount_line, string='Subtotal', digits_compute= dp.get_precision('Account')),
|
||||
'price_reduce': fields.function(_get_price_reduce, type='float', string='Price Reduce', digits_compute=dp.get_precision('Product Price')),
|
||||
'tax_id': fields.many2many('account.tax', 'sale_order_tax', 'order_line_id', 'tax_id', 'Taxes', readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'tax_id': fields.many2many('account.tax', 'sale_order_tax', 'order_line_id', 'tax_id', 'Taxes', readonly=True, states={'draft': [('readonly', False)]}, domain=['|', ('active', '=', False), ('active', '=', True)]),
|
||||
'address_allotment_id': fields.many2one('res.partner', 'Allotment Partner',help="A partner to whom the particular product needs to be allotted."),
|
||||
'product_uom_qty': fields.float('Quantity', digits_compute= dp.get_precision('Product UoS'), required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'product_uom': fields.many2one('product.uom', 'Unit of Measure ', required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
|
|
Loading…
Reference in New Issue