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 # The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms. # copyright notices and license terms.
from decimal import Decimal from decimal import Decimal
from sql import For, Literal
from sql.operators import And from sql.operators import And
from sql.aggregate import Sum from sql.aggregate import Sum
from sql.conditionals import Coalesce from sql.conditionals import Coalesce
@ -84,6 +85,16 @@ class Sale(metaclass=PoolMeta):
Invoice.write(*invoices) Invoice.write(*invoices)
return list(to_post) 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 @classmethod
def workflow_to_end(cls, sales): def workflow_to_end(cls, sales):
pool = Pool() pool = Pool()
@ -99,13 +110,16 @@ class Sale(metaclass=PoolMeta):
cls.process([sale]) cls.process([sale])
if not sale.invoices and sale.invoice_method == 'order': if not sale.invoices and sale.invoice_method == 'order':
raise UserError(gettext( raise UserError(
'sale_payment.not_customer_invoice', gettext(
reference=sale.reference)) 'sale_payment.not_customer_invoice',
reference=sale.reference
))
to_post = cls.set_invoices_to_be_posted(sales) to_post = cls.set_invoices_to_be_posted(sales)
if to_post: if to_post:
Invoice.post(to_post) with Transaction().set_context(_skip_warnings=True):
Invoice.post(to_post)
to_save = [] to_save = []
to_do = [] to_do = []
@ -339,10 +353,23 @@ class WizardSalePayment(Wizard):
) )
def transition_pay_(self): 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) if database.has_select_for():
sale = Sale(active_id) 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) line = self.get_statement_line(sale)
if line: if line:
@ -350,7 +377,7 @@ class WizardSalePayment(Wizard):
if sale.total_amount != sale.paid_amount: if sale.total_amount != sale.paid_amount:
return 'start' return 'start'
if sale.state != 'draft': if sale.state not in ('draft', 'quotation', 'confirmed'):
return 'end' return 'end'
sale.description = sale.reference sale.description = sale.reference

View File

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