[REV] purchase_stock: prepare for the merge of purchase_price_diff
This reverts commit f1d8f7b43c29342aecb69f233fdd7702b4e4d913. The previous commit shouldn't been merged to maintain the integrity of runbot testing. It will be merge soon in the same time than the migration script Part-of: odoo/odoo#109814
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
'views/res_config_settings_views.xml',
|
||||
'views/res_partner_views.xml',
|
||||
'views/stock_lot_views.xml',
|
||||
'views/product_views.xml',
|
||||
'report/purchase_report_views.xml',
|
||||
'report/purchase_report_templates.xml',
|
||||
'report/report_stock_forecasted.xml',
|
||||
|
||||
@@ -42,13 +42,8 @@ class AccountMove(models.Model):
|
||||
continue
|
||||
|
||||
# Retrieve accounts needed to generate the price difference.
|
||||
if line.product_id.cost_method == 'standard':
|
||||
debit_expense_account = line.product_id.property_account_creditor_price_difference \
|
||||
or line.product_id.categ_id.property_account_creditor_price_difference_categ
|
||||
debit_expense_account = line.move_id.fiscal_position_id.map_account(debit_expense_account)
|
||||
else:
|
||||
accounts = line.product_id.product_tmpl_id.get_product_accounts(fiscal_pos=move.fiscal_position_id)
|
||||
debit_expense_account = accounts['expense']
|
||||
accounts = line.product_id.product_tmpl_id.get_product_accounts(fiscal_pos=move.fiscal_position_id)
|
||||
debit_expense_account = accounts['expense']
|
||||
if not debit_expense_account:
|
||||
continue
|
||||
|
||||
@@ -75,21 +70,14 @@ class AccountMove(models.Model):
|
||||
valuation_price_unit = line.product_id.uom_id._compute_price(valuation_price_unit, line.product_uom_id)
|
||||
|
||||
else:
|
||||
price_unit = line.product_id.uom_id._compute_price(line.product_id.standard_price, line.product_uom_id)
|
||||
price_unit = -price_unit if line.move_id.move_type == 'in_refund' else price_unit
|
||||
valuation_price_unit = line.company_currency_id._convert(
|
||||
price_unit, move.currency_id,
|
||||
move.company_id, fields.Date.today(), round=False
|
||||
)
|
||||
continue
|
||||
|
||||
|
||||
price_unit = line._get_gross_unit_price()
|
||||
|
||||
price_unit_val_dif = price_unit - valuation_price_unit
|
||||
# If there are some valued moves, we only consider their quantity already used
|
||||
if line.product_id.cost_method == 'standard':
|
||||
relevant_qty = line.quantity
|
||||
else:
|
||||
relevant_qty = line._get_out_and_not_invoiced_qty(valuation_stock_moves)
|
||||
relevant_qty = line._get_out_and_not_invoiced_qty(valuation_stock_moves)
|
||||
price_subtotal = relevant_qty * price_unit_val_dif
|
||||
|
||||
# We consider there is a price difference if the subtotal is not zero. In case a
|
||||
|
||||
@@ -5,24 +5,10 @@ from odoo import api, fields, models
|
||||
from odoo.osv import expression
|
||||
|
||||
|
||||
class ProductCategory(models.Model):
|
||||
_inherit = "product.category"
|
||||
|
||||
property_account_creditor_price_difference_categ = fields.Many2one(
|
||||
'account.account', string="Price Difference Account",
|
||||
company_dependent=True,
|
||||
help="This account will be used to value price difference between purchase price and accounting cost.")
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_name = 'product.template'
|
||||
_inherit = 'product.template'
|
||||
|
||||
property_account_creditor_price_difference = fields.Many2one(
|
||||
'account.account', string="Price Difference Account", company_dependent=True,
|
||||
help="This account is used in automated inventory valuation to "\
|
||||
"record the price difference between a purchase order and its related vendor bill when validating this vendor bill.")
|
||||
|
||||
@api.model
|
||||
def _get_buy_route(self):
|
||||
buy_route = self.env.ref('purchase_stock.route_warehouse0_buy', raise_if_not_found=False)
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_category_property_form" model="ir.ui.view">
|
||||
<field name="name">product.category.property.form.inherit.purchase.stock</field>
|
||||
<field name="model">product.category</field>
|
||||
<field name="inherit_id" ref="account.view_category_property_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="property_account_income_categ_id" position="before">
|
||||
<field name="property_account_creditor_price_difference_categ"
|
||||
domain="[('deprecated','=',False)]" groups="account.group_account_readonly"
|
||||
attrs="{'invisible':[('property_valuation', '=', 'manual_periodic')]}"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="product_template_form_view" model="ir.ui.view">
|
||||
<field name="name">product.normal.form.inherit.purchase.stock</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="account.product_template_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="property_account_expense_id" position="after">
|
||||
<field name="property_account_creditor_price_difference" domain="[('deprecated','=',False)]" attrs="{'readonly':[('purchase_ok', '=', 0)]}" groups="account.group_account_readonly"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user