Hello everyone
I have entered a customised margin field, which represents the pre-customised margin I would like on the product.
How can I make sure that, based on the purchase price and the margin I enter in that field, the final price is calculated and updated every time I change the margin field or the cost field?
I was thinking of doing an automated action, but I can't figure out if it's OK
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
704
Views
Hi,
Try refer the following code.
class ProductProduct(models.Model):
_inherit = 'product.product'
custom_margin = fields.Float(string="Custom Margin")
list_price = fields.Float(string="Sale Price", compute="_compute_custom_price", store=True)
@api.depends('standard_price', 'custom_margin')
def _compute_custom_price(self):
for product in self:
product.list_price = product.standard_price * (1 + product.custom_margin)
Regards
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Sep 24
|
121 | ||
|
0
May 24
|
23 | ||
|
1
Apr 24
|
2623 | ||
|
0
Mar 24
|
419 | ||
|
0
Mar 24
|
542 |