From fcc5c3866a3d7a5752b3ca3ab76dcf02f09eaead Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Tue, 9 Jun 2026 14:00:22 +0200 Subject: [PATCH] Confirmed --- modules/purchase_trade/purchase.py | 29 +- modules/purchase_trade/sale.py | 23 +- modules/sale/sale_melya.fodt | 1030 ++++++++++++++-------------- 3 files changed, 574 insertions(+), 508 deletions(-) diff --git a/modules/purchase_trade/purchase.py b/modules/purchase_trade/purchase.py index ddfa251..b156e86 100755 --- a/modules/purchase_trade/purchase.py +++ b/modules/purchase_trade/purchase.py @@ -1,12 +1,12 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. from functools import wraps -from trytond.model import ModelSingleton, ModelSQL, ModelView, fields +from trytond.model import ModelSingleton, ModelSQL, ModelView, Workflow, fields from trytond.i18n import gettext from trytond.report import Report from trytond.pool import Pool, PoolMeta from trytond.pyson import Bool, Eval, Id, If, PYSONEncoder -from trytond.model import (ModelSQL, ModelView) +from trytond.model import (ModelSQL, ModelView) from trytond.tools import (cursor_dict, is_full_text, lstrip_wildcard) from trytond.transaction import Transaction, inactive_records from decimal import getcontext, Decimal, ROUND_HALF_UP @@ -264,11 +264,32 @@ class PurchaseCrop(ModelSQL,ModelView): class Purchase(metaclass=PoolMeta): __name__ = 'purchase.purchase' + @classmethod + def __setup__(cls): + super().__setup__() + cls._transitions.discard(('confirmed', 'processing')) + cls._buttons['process'] = { + 'invisible': True, + 'depends': ['state'], + } + @classmethod @ModelView.button + @Workflow.transition('confirmed') def confirm(cls, purchases): - # Confirm is disabled in Trad'ON; keep the record in quotation. - pass + pool = Pool() + Line = pool.get('purchase.line') + cls.set_purchase_date(purchases) + lines = list(sum((p.lines for p in purchases), ())) + Line._validate(lines, ['unit_price']) + cls.store_cache(purchases) + + @classmethod + @ModelView.button + def process(cls, purchases): + purchases = [p for p in purchases if p.state != 'confirmed'] + if purchases: + super().process(purchases) btb = fields.Many2One('back.to.back',"Back to back") charter_conditions = fields.One2Many( diff --git a/modules/purchase_trade/sale.py b/modules/purchase_trade/sale.py index ee931a4..d35bb8d 100755 --- a/modules/purchase_trade/sale.py +++ b/modules/purchase_trade/sale.py @@ -1,6 +1,6 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from trytond.model import fields +from trytond.model import fields, Workflow from trytond.pool import Pool, PoolMeta from trytond.pyson import Bool, Eval, Id, If, PYSONEncoder from trytond.model import (ModelSQL, ModelView) @@ -229,11 +229,28 @@ class Lot(metaclass=PoolMeta): class Sale(metaclass=PoolMeta): __name__ = 'sale.sale' + @classmethod + def __setup__(cls): + super().__setup__() + cls._transitions.discard(('confirmed', 'processing')) + cls._buttons['process'] = { + 'invisible': True, + 'depends': ['state'], + } + @classmethod @ModelView.button + @Workflow.transition('confirmed') def confirm(cls, sales): - # Confirm is disabled in Trad'ON; keep the record in quotation. - pass + cls.set_sale_date(sales) + cls.store_cache(sales) + + @classmethod + @ModelView.button + def process(cls, sales): + sales = [s for s in sales if s.state != 'confirmed'] + if sales: + super().process(sales) btb = fields.Many2One('back.to.back',"Back to back") charter_conditions = fields.One2Many( diff --git a/modules/sale/sale_melya.fodt b/modules/sale/sale_melya.fodt index b8c792a..1078228 100644 --- a/modules/sale/sale_melya.fodt +++ b/modules/sale/sale_melya.fodt @@ -1,10 +1,10 @@ - LibreOffice/7.6.0.3$Windows_X86_64 LibreOffice_project/69edd8b8ebc41d00b4de3915dc82f8f0fc3b62652026-06-09T11:12:02.599000000PT1H36M33S26 + LibreOffice/7.6.0.3$Windows_X86_64 LibreOffice_project/69edd8b8ebc41d00b4de3915dc82f8f0fc3b62652026-06-09T13:55:57.190000000PT1H39M38S29 - 11882 + 0 0 36352 18332 @@ -13,12 +13,12 @@ view2 - 9675 - 8548 + 10781 + 7087 0 - 11882 + 0 36350 - 30212 + 18330 0 0 false @@ -91,7 +91,7 @@ false false false - 3372279 + 3432369 1822556 false false @@ -168,7 +168,7 @@ - + @@ -226,6 +226,10 @@ + + + + @@ -351,9 +355,8 @@ - - - + + @@ -362,261 +365,13 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -625,239 +380,514 @@ - - + + + + + + + + + + + + + + + - + - - + + - + - + + + + + + + + + + + + + - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - - - - - - - - - - - - + + - - - - - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + @@ -877,13 +907,13 @@ - VAT NR. – NOT SUBJECT TO VAT IN SWITZERLAND - We certify this invoice authentic and definitivePage 1/3 + NOT SUBJECT TO SWISS VAT, transaction executed abroad-art7 al.1 let. AL TVA + We certify this invoice authentic and definitivePage 1/1 - + @@ -1771,17 +1801,15 @@ AAAASUVORK5CYII= - PROFORMA INVOICE - Order reference:Date: - <sale.report_melya_proforma_number><format_date(sale.sale_date, sale.party.lang) if sale.sale_date else ''> - - - Buyer: - <for each="line in sale.report_melya_buyer_address.splitlines()"> - <line> - </for> - - + PROFORMA INVOICE + Order reference:Date: + <sale.report_melya_proforma_number><format_date(sale.sale_date, sale.party.lang) if sale.sale_date else ''> + + Buyer: + <for each="line in sale.report_melya_buyer_address.splitlines()"> + <line> + </for> + @@ -1789,83 +1817,83 @@ - Quantity + Quantity - Goods Description + Goods Description - Unit Price + Unit Price - Amount + Amount - - - - <format_number(sale.lines[0].quantity, sale.party.lang, digits=4) if sale.lines else ''><sale.lines[0].unit.rec_name.upper() if sale.lines and sale.lines[0].unit else ''> + + + + <format_number(sale.lines[0].quantity, sale.party.lang, digits=4) if sale.lines else ''><sale.lines[0].unit.rec_name.upper() if sale.lines and sale.lines[0].unit else ''> - - - - <sale.report_product_name or ''> - <sale.report_product_description or ''> - + + + + <sale.report_product_name or ''> + <sale.report_product_description or ''> + - - - - <format_currency(sale.lines[0].unit_price, sale.party.lang, sale.currency) if sale.lines else ''> + + + + <format_currency(sale.lines[0].unit_price, sale.party.lang, sale.currency) if sale.lines else ''> - - - - <format_currency(sale.lines[0].amount, sale.party.lang, sale.currency)> + + + + <format_currency(sale.lines[0].amount, sale.party.lang, sale.currency)> - - Total quantity: <format_number(sale.lines[0].quantity, sale.party.lang, digits=4) if sale.lines else ''><sale.lines[0].unit.rec_name.upper() if sale.lines and sale.lines[0].unit else ''> + + Total quantity: <format_number(sale.lines[0].quantity, sale.party.lang, digits=4) if sale.lines else ''><sale.lines[0].unit.rec_name.upper() if sale.lines and sale.lines[0].unit else ''> - Total amount: <format_currency(sale.lines[0].amount, sale.party.lang, sale.currency)> - - - SHIPMENT SCHEDULE:<sale.report_delivery_period_description or ''> - - TOLERANCE:+/- <sale.tol_min>% - - ORIGIN:<sale.product_origin> - - TRANSPORTATION BY:VESSEL - - DELIVERY TERMS:<sale.report_melya_incoterm> - - PAYMENT TERMS:<sale.payment_term.description if sale.payment_term else ''> - - BANK DETAILS:<sale.report_melya_bank_name> - <sale.report_melya_bank_address> - <sale.report_melya_bank_account_line> - - - DELIVERY IS SUBJECT TO THE DELIVERY BY OUR SUPPLIER. - - - Signed by :Signed by : - (The Seller)(The Buyer) - - MELYA SA - 13 RUE ROBERT CEARD - CH-1204 GENEVA - SWITZERLAND - + Total amount: <format_currency(sale.lines[0].amount, sale.party.lang, sale.currency)> + + + SHIPMENT SCHEDULE:<sale.report_delivery_period_description or ''> + + TOLERANCE:+/- <sale.tol_min>% + + ORIGIN:<sale.product_origin> + + TRANSPORTATION BY:VESSEL + + DELIVERY TERMS:<sale.report_melya_incoterm> + + PAYMENT TERMS:<sale.payment_term.description if sale.payment_term else ''> + + BANK DETAILS:<sale.report_melya_bank_name> + <sale.report_melya_bank_address> + <sale.report_melya_bank_account_line> + + + DELIVERY IS SUBJECT TO THE DELIVERY BY OUR SUPPLIER. + + + Signed by :Signed by : + (The Seller)(The Buyer) + + MELYA SA + 13 RUE ROBERT CEARD + CH-1204 GENEVA + SWITZERLAND + </for> - + \ No newline at end of file