fix: Update 7.6

This commit is contained in:
Rodia 2025-07-27 00:15:32 -03:00
parent 5b8f0397b1
commit ccda3c7734
2 changed files with 37 additions and 10 deletions

43
sale.py
View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
from decimal import Decimal
from sql import For, Literal
from sql.operators import And
from sql.aggregate import Sum
from sql.conditionals import Coalesce
@ -84,6 +85,16 @@ class Sale(metaclass=PoolMeta):
Invoice.write(*invoices)
return list(to_post)
@classmethod
@ModelView.button
def process(cls, sales):
states = {'confirmed', 'processing', 'done'}
sales = [s for s in sales if s.state in states]
cls._process_invoice(sales)
cls._process_shipment(sales)
cls._process_invoice_shipment_states(sales)
cls._process_state(sales)
@classmethod
def workflow_to_end(cls, sales):
pool = Pool()
@ -99,13 +110,16 @@ class Sale(metaclass=PoolMeta):
cls.process([sale])
if not sale.invoices and sale.invoice_method == 'order':
raise UserError(gettext(
'sale_payment.not_customer_invoice',
reference=sale.reference))
raise UserError(
gettext(
'sale_payment.not_customer_invoice',
reference=sale.reference
))
to_post = cls.set_invoices_to_be_posted(sales)
if to_post:
Invoice.post(to_post)
with Transaction().set_context(_skip_warnings=True):
Invoice.post(to_post)
to_save = []
to_do = []
@ -339,10 +353,23 @@ class WizardSalePayment(Wizard):
)
def transition_pay_(self):
Sale = Pool().get('sale.sale')
pool = Pool()
Sale = pool.get('sale.sale')
sale = Sale(Transaction().context['active_id'])
transaction = Transaction()
database = transaction.database
connection = transaction.connection
active_id = Transaction().context.get('active_id', False)
sale = Sale(active_id)
if database.has_select_for():
table = Sale.__table__()
query = table.select(
Literal(1),
where=(table.id == sale.id),
for_=For('UPDATE', nowait=True))
with connection.cursor() as cursor:
cursor.execute(*query)
else:
Sale.lock()
line = self.get_statement_line(sale)
if line:
@ -350,7 +377,7 @@ class WizardSalePayment(Wizard):
if sale.total_amount != sale.paid_amount:
return 'start'
if sale.state != 'draft':
if sale.state not in ('draft', 'quotation', 'confirmed'):
return 'end'
sale.description = sale.reference

View File

@ -408,8 +408,8 @@ class StatementLine(ModelView):
if company:
return Company(company).currency.id
@fields.depends('end_balance', 'real_cash', 'mismatch')
@fields.depends(
'end_balance', 'real_cash', 'mismatch')
def on_change_real_cash(self):
if self.real_cash and self.end_balance:
self.mismatch = self.real_cash - self.end_balance