round incoming unit_price and quantity to match digits of fields
This commit is contained in:
parent
5fc191697a
commit
d52774a77e
2 changed files with 21 additions and 17 deletions
14
document.py
14
document.py
|
@ -20,6 +20,7 @@ from trytond.i18n import gettext
|
|||
from trytond.model import fields
|
||||
from trytond.pyson import Eval
|
||||
from trytond.protocols.jsonrpc import JSONEncoder
|
||||
from trytond.modules.product import round_price
|
||||
|
||||
|
||||
xml_types = [
|
||||
|
@ -719,12 +720,15 @@ class Incoming(metaclass=PoolMeta):
|
|||
if units:
|
||||
xml_uom = units[0]
|
||||
|
||||
unitprice = line_data.get('unit_net_price', {}).pop('amount', None)
|
||||
line = Line(
|
||||
invoice=invoice,
|
||||
type='line',
|
||||
unit=xml_uom,
|
||||
quantity=line_data.get('quantity', {}).pop('billed', None),
|
||||
unit_price=line_data.get('unit_net_price', {}).pop('amount', None))
|
||||
quantity=xml_uom.round(
|
||||
line_data.get('quantity', {}).pop('billed', None)),
|
||||
unit_price=round_price(unitprice)
|
||||
if unitprice is not None else Decimal('0.0'))
|
||||
line_no = line_data.pop('line_no', None)
|
||||
|
||||
# description
|
||||
|
@ -963,9 +967,9 @@ class Incoming(metaclass=PoolMeta):
|
|||
result['quantity'] = self._readxml_read_listdata(
|
||||
xmldata, xpath_line, [
|
||||
'ram:SpecifiedLineTradeDelivery'], [
|
||||
('ram:BilledQuantity', 'billed', Decimal),
|
||||
('ram:ChargeFreeQuantity', 'chargefree', Decimal),
|
||||
('ram:PackageQuantity', 'package', Decimal),
|
||||
('ram:BilledQuantity', 'billed', float),
|
||||
('ram:ChargeFreeQuantity', 'chargefree', float),
|
||||
('ram:PackageQuantity', 'package', float),
|
||||
])[0]
|
||||
result['quantity']['unit_code'] = self._readxml_getattrib(
|
||||
xmldata, xpath_quantity + ['ram:BilledQuantity'], 'unitCode')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue