Skip to Content
Menu
This question has been flagged
1 Odpoveď
11598 Zobrazenia

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
Zrušiť
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
Zrušiť
Related Posts Replies Zobrazenia Aktivita
2
júl 24
2322
1
jún 24
4844
1
okt 23
10470
1
okt 23
98
1
aug 23
2193