diff --git a/data/fields_default.xml b/data/fields_default.xml index 511dc66..73d9d14 100755 --- a/data/fields_default.xml +++ b/data/fields_default.xml @@ -370,7 +370,11 @@ ctx = { # "delivery_address": self.delivery_address, "commitment_date": self.commitment_date, + "products_amount": len(self.order_line.filtered(lambda rec: not rec.display_type)), + "amount_untaxed": self.amount_untaxed, + "amount_tax": self.amount_tax, "amount_total": self.amount_total, + "terms_and_conditions": self.note, # "payment_part_one": self.payment_part_one, # "payment_part_two": self.payment_part_two, @@ -500,9 +504,6 @@ action = ctx -1 - - - @@ -558,11 +559,47 @@ action = ctx 3 + + Products amount + products_amount + + Total products amount in Sale order, including services and goods. + + 3 + + + + Amount untaxed + amount_untaxed + + Sale order total amount without taxes + + 4 + + + + Amount tax + amount_tax + + Sale order total taxes amount + + 4 + + Amount total amount_total - Sale order total amount + Sale order total amount including taxes + + 4 + + + + Terms and conditions + terms_and_conditions + + Terms and conditions from Sale order 4 diff --git a/models/res_partner.py b/models/res_partner.py index 55173d1..8f6025f 100755 --- a/models/res_partner.py +++ b/models/res_partner.py @@ -63,7 +63,7 @@ class ResPartner(models.Model): record.city, record.country_id.l10n_ru_short_name or record.country_id.name, ], - ) + ), ) record.full_address = ", ".join(address_data) diff --git a/utils/num2words.py b/utils/num2words.py index 54894a8..c870042 100755 --- a/utils/num2words.py +++ b/utils/num2words.py @@ -1,7 +1,7 @@ from decimal import Decimal from num2words import num2words -from num2words import CONVERTER_CLASSES, CONVERTES_TYPES +from num2words import CONVERTES_TYPES # Can use params: diff --git a/wizard/res_partner_contract_wizard.py b/wizard/res_partner_contract_wizard.py index 2b18496..4e1e286 100755 --- a/wizard/res_partner_contract_wizard.py +++ b/wizard/res_partner_contract_wizard.py @@ -224,33 +224,45 @@ class ContractWizard(models.TransientModel): } ) # Extend with order product lines - if hasattr(self.target, "order_id") and self.target.order_id.order_line: + if ( + self.target._name == "sale.order" + or hasattr(self.target, "order_id") + and self.target.order_id.order_line + ): def number_generator(n=1): while True: yield n n += 1 + sale_order_rec = ( + self.target + if self.target._name == "sale.order" + else self.target.order_id + ) counter = number_generator() - fields.update( { "products": [ { "number": next(counter), + "vendor_code": item.product_id.default_code, "label": item.product_id.display_name, "description": item.name, + # "uom": item.product_id.uom_po_id.name, "count": item.product_uom_qty, "unit": item.product_uom.name, "cost": self.to_fixed(item.price_unit), + "cost_wo_vat": self.to_fixed(item.price_reduce_taxexcl), "discount": self.to_fixed(item.discount), "subtotal": self.to_fixed(item.price_subtotal), + "currency_symbol": item.currency_id.symbol, "display_type": item.display_type, } - for item in self.target.order_id.order_line or [] + for item in sale_order_rec.order_line or [] ], "total_amount": self.to_fixed( - sum(self.target.order_id.order_line.mapped("price_subtotal")) + sum(sale_order_rec.order_line.mapped("price_subtotal")) ), } )