Allow unit_price is 0 when create intercompany sale

#162990
This commit is contained in:
Raimon Esteve 2023-10-24 16:14:38 +02:00
parent 01798089d5
commit 94b3e46900
4 changed files with 1 additions and 18 deletions

View File

@ -2,10 +2,6 @@
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:purchase.purchase:"
msgid "Product \"%(product)s\" misses an unit price."
msgstr "Falta el preu unitari pel producte \"%(product)s\"."
msgctxt "error:purchase.purchase:"
msgid ""
"The purchase \"%s\" has to be assigned to a delivery address or a warehouse with"

View File

@ -2,10 +2,6 @@
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:purchase.purchase:"
msgid "Product \"%(product)s\" misses an unit price."
msgstr "Falta el precio unitario para el producto \"%(product)s\"."
msgctxt "error:purchase.purchase:"
msgid ""
"The purchase \"%s\" has to be assigned to a delivery address or a warehouse with"

View File

@ -6,8 +6,5 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.message" id="empty_address">
<field name="text">The purchase "%(purchase)s" has to be assigned to a delivery address or a warehouse with an address assigned.</field>
</record>
<record model="ir.message" id="missing_unit_price">
<field name="text">Product "%(product)s" misses an unit price.</field>
</record>
</data>
</tryton>

View File

@ -3,8 +3,6 @@
from trytond.pool import Pool, PoolMeta
from trytond.model import ModelView
from trytond.transaction import Transaction
from trytond.i18n import gettext
from trytond.exceptions import UserError
from trytond.modules.product import round_price
@ -101,12 +99,8 @@ class Purchase(metaclass=PoolMeta):
sale_line.unit = line.unit
sale_line.quantity = line.quantity
sale_line.on_change_product()
if not sale_line.unit_price:
if sale_line.unit_price is None:
sale_line.unit_price = line.unit_price
if not sale_line.unit_price:
raise UserError(gettext(
'intercompany_create_sales_from_purchase.missing_unit_price',
product=product.rec_name))
if hasattr(SaleLine, 'gross_unit_price'):
sale_line.gross_unit_price = round_price(sale_line.unit_price)
sale_line.purchase_line = line