-
Notifications
You must be signed in to change notification settings - Fork 108
[FIX]product_replenishment_cost: remove logic from standard price #892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 19.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,24 +48,32 @@ def _compute_price_unit_and_date_planned_and_name(self): | |
|
|
||
| @api.model | ||
| def _prepare_purchase_order_line(self, product_id, product_qty, product_uom, company_id, supplier, po): | ||
| # Para casos como cuando se viene de reabastecimientos, usamos el nuevo net_price en vez de price | ||
| # Use net_price instead of raw price (net_price includes replenishment cost rules) | ||
| res = super()._prepare_purchase_order_line(product_id, product_qty, product_uom, company_id, supplier, po) | ||
|
|
||
| # Check if supplier is a product.supplierinfo or res.partner | ||
| # When called from procurement, supplier is res.partner (supplier.partner_id from core) | ||
| # When called directly, supplier is product.supplierinfo | ||
| if supplier and supplier._name == "product.supplierinfo": | ||
| price_unit = ( | ||
| self.env["account.tax"]._fix_tax_included_price_company( | ||
| supplier.net_price, product_id.supplier_taxes_id, self.tax_ids, company_id | ||
| ) | ||
| if supplier | ||
| else 0.0 | ||
| today = fields.Date.today() | ||
| # supplier can be product.supplierinfo (direct call) or res.partner (from procurement via purchase_stock) | ||
| if supplier._name == "product.supplierinfo": | ||
| seller = supplier | ||
| else: | ||
| seller = product_id.with_company(company_id)._select_seller( | ||
| partner_id=supplier, | ||
| quantity=product_qty, | ||
| date=po.date_order and po.date_order.date() or today, | ||
| uom_id=product_uom, | ||
| ) | ||
|
Comment on lines
+54
to
64
|
||
| if price_unit and supplier and po.currency_id and supplier.currency_id != po.currency_id: | ||
| price_unit = supplier.currency_id._convert( | ||
| price_unit, po.currency_id, po.company_id, po.date_order or fields.Date.today() | ||
| ) | ||
| res["price_unit"] = price_unit | ||
| if not seller: | ||
| return res | ||
|
|
||
| tax_domain = self.env["account.tax"]._check_company_domain(company_id) | ||
| product_taxes = product_id.supplier_taxes_id.filtered_domain(tax_domain) | ||
| taxes = po.fiscal_position_id.map_tax(product_taxes) | ||
| price_unit = self.env["account.tax"]._fix_tax_included_price_company( | ||
| seller.net_price, product_taxes, taxes, company_id | ||
| ) | ||
| if price_unit and po.currency_id and seller.currency_id != po.currency_id: | ||
| price_unit = seller.currency_id._convert(price_unit, po.currency_id, po.company_id, po.date_order or today) | ||
| if product_uom and seller.product_uom_id and seller.product_uom_id != product_uom: | ||
| price_unit = seller.product_uom_id._compute_price(price_unit, product_uom) | ||
| res["price_unit"] = price_unit | ||
| return res | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1 @@ | ||
| from . import stock_rule | ||
| from . import purchase_order_line |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
En
_prepare_purchase_order_line, se quitó el chequeosupplier and ...y ahora se accede asupplier._namedirectamente. Sisupplierllega comoFalse/None(caso que antes estaba contemplado), esto va a lanzarAttributeError. Recomendación: volver a proteger el acceso (p. ej. tratarsupplierfalsy como “sin seller” y hacerreturn reso resolver el seller con_select_sellersolo cuando corresponda).