bemade_margin_vendor_pricelist: add dependency to product_pricelist_supplierinfo + formatting
This commit is contained in:
parent
73c74412e0
commit
f830cb676f
2 changed files with 21 additions and 14 deletions
|
|
@ -24,7 +24,12 @@
|
|||
"author": "Bemade Inc.",
|
||||
"website": "https://www.bemade.org",
|
||||
"license": "LGPL-3",
|
||||
"depends": ["sale_stock_margin", "sale_management", "stock"],
|
||||
"depends": [
|
||||
"sale_stock_margin",
|
||||
"sale_management",
|
||||
"stock",
|
||||
"product_pricelist_supplierinfo",
|
||||
],
|
||||
"data": ["views/sale_order.xml"],
|
||||
"installable": True,
|
||||
"auto_install": False,
|
||||
|
|
|
|||
|
|
@ -3,21 +3,23 @@ from odoo.tools.float_utils import float_is_zero, float_compare
|
|||
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = 'sale.order'
|
||||
_inherit = "sale.order"
|
||||
|
||||
gross_profit = fields.Monetary("Gross Profit", compute='_compute_margin_actual', store=False)
|
||||
|
||||
gross_profit_percent = fields.Float(
|
||||
string='Gross Profit (%)',
|
||||
compute='_compute_margin_actual',
|
||||
store=False,
|
||||
group_operator='avg'
|
||||
gross_profit = fields.Monetary(
|
||||
"Gross Profit", compute="_compute_margin_actual", store=False
|
||||
)
|
||||
|
||||
@api.depends('order_line.gross_profit', 'amount_untaxed')
|
||||
gross_profit_percent = fields.Float(
|
||||
string="Gross Profit (%)",
|
||||
compute="_compute_margin_actual",
|
||||
store=False,
|
||||
aggregator="avg",
|
||||
)
|
||||
|
||||
@api.depends("order_line.gross_profit", "amount_untaxed")
|
||||
def _compute_margin_actual(self):
|
||||
for order in self:
|
||||
order.gross_profit = sum(order.order_line.mapped('gross_profit'))
|
||||
order.gross_profit_percent = order.amount_untaxed and order.gross_profit / order.amount_untaxed
|
||||
|
||||
|
||||
order.gross_profit = sum(order.order_line.mapped("gross_profit"))
|
||||
order.gross_profit_percent = (
|
||||
order.amount_untaxed and order.gross_profit / order.amount_untaxed
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue