Use strings on fields compute to allow inheritance

This commit is contained in:
Akim Juillerat
2019-03-18 17:38:46 +01:00
parent a6efa3b5e4
commit 21d340cc23
5 changed files with 24 additions and 22 deletions

View File

@@ -63,14 +63,16 @@ class RmaOrder(models.Model):
comodel_name='res.partner', string='Partner', required=True)
rma_line_ids = fields.One2many('rma.order.line', 'rma_id',
string='RMA lines')
in_shipment_count = fields.Integer(compute=_compute_in_shipment_count,
in_shipment_count = fields.Integer(compute='_compute_in_shipment_count',
string='# of Invoices')
out_shipment_count = fields.Integer(compute=_compute_out_shipment_count,
out_shipment_count = fields.Integer(compute='_compute_out_shipment_count',
string='# of Outgoing Shipments')
line_count = fields.Integer(compute=_compute_line_count,
line_count = fields.Integer(compute='_compute_line_count',
string='# of Outgoing Shipments')
supplier_line_count = fields.Integer(compute=_compute_supplier_line_count,
string='# of Outgoing Shipments')
supplier_line_count = fields.Integer(
compute='_compute_supplier_line_count',
string='# of Outgoing Shipments'
)
company_id = fields.Many2one('res.company', string='Company',
required=True, default=lambda self:
self.env.user.company_id)

View File

@@ -240,9 +240,9 @@ class RmaOrderLine(models.Model):
string='Price Unit',
readonly=True, states={'draft': [('readonly', False)]},
)
in_shipment_count = fields.Integer(compute=_compute_in_shipment_count,
in_shipment_count = fields.Integer(compute='_compute_in_shipment_count',
string='# of Shipments')
out_shipment_count = fields.Integer(compute=_compute_out_shipment_count,
out_shipment_count = fields.Integer(compute='_compute_out_shipment_count',
string='# of Deliveries')
move_ids = fields.One2many('stock.move', 'rma_line_id',
string='Stock Moves', readonly=True,
@@ -336,40 +336,40 @@ class RmaOrderLine(models.Model):
qty_to_receive = fields.Float(
string='Qty To Receive',
digits=dp.get_precision('Product Unit of Measure'),
compute=_compute_qty_to_receive, store=True)
compute='_compute_qty_to_receive', store=True)
qty_incoming = fields.Float(
string='Incoming Qty', copy=False,
readonly=True, digits=dp.get_precision('Product Unit of Measure'),
compute=_compute_qty_incoming, store=True)
compute='_compute_qty_incoming', store=True)
qty_received = fields.Float(
string='Qty Received', copy=False,
digits=dp.get_precision('Product Unit of Measure'),
compute=_compute_qty_received,
compute='_compute_qty_received',
store=True)
qty_to_deliver = fields.Float(
string='Qty To Deliver', copy=False,
digits=dp.get_precision('Product Unit of Measure'),
readonly=True, compute=_compute_qty_to_deliver,
readonly=True, compute='_compute_qty_to_deliver',
store=True)
qty_outgoing = fields.Float(
string='Outgoing Qty', copy=False,
readonly=True, digits=dp.get_precision('Product Unit of Measure'),
compute=_compute_qty_outgoing,
compute='_compute_qty_outgoing',
store=True)
qty_delivered = fields.Float(
string='Qty Delivered', copy=False,
digits=dp.get_precision('Product Unit of Measure'),
readonly=True, compute=_compute_qty_delivered,
readonly=True, compute='_compute_qty_delivered',
store=True)
qty_to_supplier_rma = fields.Float(
string='Qty to send to Supplier RMA',
digits=dp.get_precision('Product Unit of Measure'),
readonly=True, compute=_compute_qty_supplier_rma,
readonly=True, compute='_compute_qty_supplier_rma',
store=True)
qty_in_supplier_rma = fields.Float(
string='Qty in Supplier RMA',
digits=dp.get_precision('Product Unit of Measure'),
readonly=True, compute=_compute_qty_supplier_rma,
readonly=True, compute='_compute_qty_supplier_rma',
store=True)
under_warranty = fields.Boolean(
string="Under Warranty?",

View File

@@ -58,7 +58,7 @@ class AccountInvoice(models.Model):
return {}
rma_count = fields.Integer(
compute=_compute_rma_count, string='# of RMA')
compute='_compute_rma_count', string='# of RMA')
add_rma_line_id = fields.Many2one(
comodel_name='rma.order.line',
@@ -156,7 +156,7 @@ class AccountInvoiceLine(models.Model):
invl.rma_line_count = len(rma_lines)
rma_line_count = fields.Integer(
compute=_compute_rma_count, string='# of RMA')
compute='_compute_rma_count', string='# of RMA')
rma_line_ids = fields.One2many(
comodel_name='rma.order.line', inverse_name='invoice_line_id',
string="RMA", readonly=True,

View File

@@ -25,9 +25,9 @@ class RmaOrder(models.Model):
ondelete='set null', readonly=True,
)
invoice_refund_count = fields.Integer(
compute=_compute_invoice_refund_count, string='# of Refunds')
compute='_compute_invoice_refund_count', string='# of Refunds')
invoice_count = fields.Integer(
compute=_compute_invoice_count, string='# of Invoices')
compute='_compute_invoice_count', string='# of Invoices')
def _prepare_rma_line_from_inv_line(self, line):
if self.type == 'customer':

View File

@@ -48,7 +48,7 @@ class RmaOrderLine(models.Model):
help="Invoice address for current rma order.",
)
refund_count = fields.Integer(
compute=_compute_refund_count, string='# of Refunds', default=0)
compute='_compute_refund_count', string='# of Refunds', default=0)
invoice_line_id = fields.Many2one(
comodel_name='account.invoice.line',
string='Originating Invoice Line',
@@ -73,11 +73,11 @@ class RmaOrderLine(models.Model):
qty_to_refund = fields.Float(
string='Qty To Refund', copy=False,
digits=dp.get_precision('Product Unit of Measure'), readonly=True,
compute=_compute_qty_to_refund, store=True)
compute='_compute_qty_to_refund', store=True)
qty_refunded = fields.Float(
string='Qty Refunded', copy=False,
digits=dp.get_precision('Product Unit of Measure'),
readonly=True, compute=_compute_qty_refunded, store=True)
readonly=True, compute='_compute_qty_refunded', store=True)
@api.onchange('product_id')
def _onchange_product_id(self):