Proxy fields defaults with lambda to allow inheritance

This commit is contained in:
Akim Juillerat
2019-03-18 17:31:56 +01:00
committed by ahenriquez
parent 4b30d8c0ba
commit 450b8a2b49
4 changed files with 18 additions and 11 deletions

View File

@@ -114,6 +114,7 @@ Contributors
* Aaron Henriquez <ahenriquez@eficent.com>
* Lois Rilo <lois.rilo@eficent.com>
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
* Akim Juillerat <akim.juillerat@camptocamp.com>
Maintainer
----------

View File

@@ -45,12 +45,12 @@ class RmaOperation(models.Model):
in_route_id = fields.Many2one(
comodel_name='stock.location.route', string='Inbound Route',
domain=[('rma_selectable', '=', True)],
default=_default_routes,
default=lambda self: self._default_routes(),
)
out_route_id = fields.Many2one(
comodel_name='stock.location.route', string='Outbound Route',
domain=[('rma_selectable', '=', True)],
default=_default_routes,
default=lambda self: self._default_routes(),
)
customer_to_supplier = fields.Boolean(
string='The customer will send to the supplier',
@@ -60,10 +60,12 @@ class RmaOperation(models.Model):
)
in_warehouse_id = fields.Many2one(
comodel_name='stock.warehouse', string='Inbound Warehouse',
default=_default_warehouse_id)
default=lambda self: self._default_warehouse_id(),
)
out_warehouse_id = fields.Many2one(
comodel_name='stock.warehouse', string='Outbound Warehouse',
default=_default_warehouse_id)
default=lambda self: self._default_warehouse_id(),
)
location_id = fields.Many2one(
'stock.location', 'Send To This Company Location')
type = fields.Selection([

View File

@@ -50,12 +50,15 @@ class RmaOrder(models.Model):
string='Group Number', index=True, copy=False)
type = fields.Selection(
[('customer', 'Customer'), ('supplier', 'Supplier')],
string="Type", required=True, default=_get_default_type, readonly=True)
string="Type", required=True,
default=lambda self: self._get_default_type(),
readonly=True
)
reference = fields.Char(string='Partner Reference',
help="The partner reference of this RMA order.")
comment = fields.Text('Additional Information')
date_rma = fields.Datetime(string='Order Date', index=True,
default=_default_date_rma)
default=lambda self: self._default_date_rma(),)
partner_id = fields.Many2one(
comodel_name='res.partner', string='Partner', required=True)
rma_line_ids = fields.One2many('rma.order.line', 'rma_id',

View File

@@ -167,7 +167,7 @@ class RmaOrderLine(models.Model):
delivery_address_id = fields.Many2one(
comodel_name='res.partner', string='Partner delivery address',
default=_default_delivery_address,
default=lambda self: self._default_delivery_address(),
readonly=True, states={'draft': [('readonly', False)]},
help="This address will be used to deliver repaired or replacement "
"products.",
@@ -258,7 +258,8 @@ class RmaOrderLine(models.Model):
default=lambda self: self.env.user.company_id)
type = fields.Selection(
selection=[('customer', 'Customer'), ('supplier', 'Supplier')],
string="Type", required=True, default=_get_default_type,
string="Type", required=True,
default=lambda self: self._get_default_type(),
readonly=True,
)
customer_to_supplier = fields.Boolean(
@@ -298,19 +299,19 @@ class RmaOrderLine(models.Model):
string='Inbound Warehouse',
required=True,
readonly=True, states={'draft': [('readonly', False)]},
default=_default_warehouse_id,
default=lambda self: self._default_warehouse_id(),
)
out_warehouse_id = fields.Many2one(
comodel_name='stock.warehouse', string='Outbound Warehouse',
required=True,
readonly=True, states={'draft': [('readonly', False)]},
default=_default_warehouse_id,
default=lambda self: self._default_warehouse_id(),
)
location_id = fields.Many2one(
comodel_name='stock.location', string='Send To This Company Location',
required=True,
readonly=True, states={'draft': [('readonly', False)]},
default=_default_location_id,
default=lambda self: self._default_location_id(),
)
customer_rma_id = fields.Many2one(
'rma.order.line', string='Customer RMA line', ondelete='cascade')