mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-26 12:31:59 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import account_move
|
||||
from . import account_move_line
|
||||
from . import sale_order_line
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models, fields
|
||||
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = "sale.order.line"
|
||||
|
||||
|
|
@ -10,24 +10,10 @@ class SaleOrderLine(models.Model):
|
|||
|
||||
@api.depends('is_expense')
|
||||
def _compute_purchase_price(self):
|
||||
date_today = fields.Date.context_today(self)
|
||||
expense_lines = self.filtered('expense_id')
|
||||
for line in expense_lines:
|
||||
if line.expense_id.product_has_cost:
|
||||
product_cost = line.expense_id.untaxed_amount / line.expense_id.quantity
|
||||
else:
|
||||
product_cost = line.expense_id.untaxed_amount
|
||||
expense = line.expense_id
|
||||
product_cost = expense.untaxed_amount_currency / (expense.quantity or 1.0)
|
||||
line.purchase_price = line._convert_to_sol_currency(product_cost, expense.currency_id)
|
||||
|
||||
from_currency = line.expense_id.currency_id
|
||||
to_currency = line.currency_id or line.order_id.currency_id
|
||||
|
||||
if to_currency and product_cost and from_currency != to_currency:
|
||||
line.purchase_price = from_currency._convert(
|
||||
from_amount=product_cost,
|
||||
to_currency=to_currency,
|
||||
company=line.company_id or self.env.company,
|
||||
date=line.order_id.date_order or date_today,
|
||||
round=False)
|
||||
else:
|
||||
line.purchase_price = product_cost
|
||||
return super(SaleOrderLine, self - expense_lines)._compute_purchase_price()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue