Skip to Content
Menu
This question has been flagged
1 Reply
11518 Views

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
Discard
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
Discard
Related Posts Replies Views Activity
2
Jul 24
2224
1
Jun 24
4776
1
Oct 23
10373
1
Oct 23
98
1
Aug 23
2193