Skip to Content
Menú
This question has been flagged
1 Respondre
11595 Vistes

i'm new in odoo dev and i'm trying to make the field value 'recommanded_price' (from marketplace.marketplaceinfo model) change when 'formula' field changes (which is in the marketplace.marketplace model)

I used the @api.depends decorator but it doesn't trigger the function when the specific

Here's the essential of my code

class marketplace(models.Model):
_name = 'marketplace.marketplace'
_description = 'Marketplace'
_sql_constraints = [
('mkp_name_uniq',
'UNIQUE (name)',
'Marketplace name must be unique')
]
formula = fields.Char('Formula')
product_ids = fields.One2many('marketplace.marketplaceinfo', 'mkp', 'Products')
class marketplace_info(models.Model):
_name = 'marketplace.marketplaceinfo'
_description = 'Information about a product marketplace'
mkp = fields.Many2one('marketplace.marketplace','Marketplace',ondelete = 'cascade',required = True,
help='Marketplace of this product'
)
product_tmpl_id = fields.Many2one(
'product.template', 'Product Template',
index=True, ondelete='cascade')
price = fields.Float('Price', default=0.0, digits=dp.get_precision('Product Price'),
help="The selling price for a product within the marketplace")
recommonded_price = fields.Float('Recommended Price', compute='_compute_recommonded_price' ,default=0.0, digits=dp.get_precision('Product Price'),
readonly = True, help="The recommended selling price for a product within the marketplace")
 
@api.depends('mkp.formula')
def _compute_recommonded_price(self):
#do something
Avatar
Descartar
Best Answer

Hi,

Your approach is correct, I've already implemented same it's works for me, instead I've worked on many2one selection type.



Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de jul. 24
2322
1
de juny 24
4842
1
d’oct. 23
10469
1
d’oct. 23
98
1
d’ag. 23
2193