diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2018-10-25 09:10:46 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2018-11-14 15:14:36 +0000 |
| commit | 50e5f73b4e2461982e5312ff0707e9d770b09f0f (patch) | |
| tree | e12603cdc66efa4e9c0eeee7705e4760352689cb /odoo/addons/test_new_api/models.py | |
| parent | c41902a21c50e0accc1b9d6bfa60bce8ecbb5955 (diff) | |
[FIX] fields, test_new_api: monetary related custom
This commit allows for not copying the currency_field attribute
of a monetary field when the monetary field is related,
and when the currency_field attribute is not explicit
Before this commit, the currency_field attribute on the related monetary
was set as the one on the distant model
After this commit, the currency_field attribute takes the field on the
current model
Though the test may appear like an incoherent use case,
it is on the contrary totally legit, as web_studio allows it
OPW 1903113
closes odoo/odoo#28144
Diffstat (limited to 'odoo/addons/test_new_api/models.py')
| -rw-r--r-- | odoo/addons/test_new_api/models.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/odoo/addons/test_new_api/models.py b/odoo/addons/test_new_api/models.py index 043ee8a0b7d..7d7ad777b44 100644 --- a/odoo/addons/test_new_api/models.py +++ b/odoo/addons/test_new_api/models.py @@ -468,3 +468,38 @@ class BinarySvg(models.Model): name = fields.Char(required=True) image_attachment = fields.Binary(attachment=True) image_wo_attachment = fields.Binary(attachment=False) + + +class MonetaryBase(models.Model): + _name = 'test_new_api.monetary_base' + _description = 'Monetary Base' + + base_currency_id = fields.Many2one('res.currency') + amount = fields.Monetary(currency_field='base_currency_id') + + +class MonetaryRelated(models.Model): + _name = 'test_new_api.monetary_related' + _description = 'Monetary Related' + + monetary_id = fields.Many2one('test_new_api.monetary_base') + currency_id = fields.Many2one('res.currency', related='monetary_id.base_currency_id') + amount = fields.Monetary(related='monetary_id.amount') + + +class MonetaryCustom(models.Model): + _name = 'test_new_api.monetary_custom' + _description = 'Monetary Related Custom' + + monetary_id = fields.Many2one('test_new_api.monetary_base') + x_currency_id = fields.Many2one('res.currency', related='monetary_id.base_currency_id') + x_amount = fields.Monetary(related='monetary_id.amount') + + +class MonetaryInherits(models.Model): + _name = 'test_new_api.monetary_inherits' + _description = 'Monetary Inherits' + _inherits = {'test_new_api.monetary_base': 'monetary_id'} + + monetary_id = fields.Many2one('test_new_api.monetary_base', required=True, ondelete='cascade') + currency_id = fields.Many2one('res.currency') |
