fix: Se corrige procesamiento de venta al finalizar envío

This commit is contained in:
sinergia 2023-11-13 12:09:02 -05:00
parent e79d6d8c8d
commit d152cd9d53

36
move.py
View File

@ -1,18 +1,39 @@
from trytond.model import fields, ModelSQL, ModelView, Workflow, dualmethod
from trytond.model import fields, ModelView, Workflow
from trytond.modules.company import CompanyReport
from trytond.modules.company.model import employee_field, set_employee
from trytond.modules.company.model import set_employee
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval, If
from trytond.exceptions import UserError
from itertools import groupby
from trytond.transaction import Transaction
from trytond.transaction import Transaction, without_check_access
from functools import wraps
def process_sale(moves_field):
def _process_sale(func):
@wraps(func)
def wrapper(cls, shipments):
pool = Pool()
Sale = pool.get('sale.sale')
transaction = Transaction()
context = transaction.context
with without_check_access():
sales = set(m.sale for s in cls.browse(shipments)
for m in getattr(s, moves_field) if m.sale)
func(cls, shipments)
if sales:
with transaction.set_context(
queue_batch=context.get('queue_batch', True)):
Sale.__queue__.process(sales)
return wrapper
return _process_sale
class Move(metaclass=PoolMeta):
"Stock Move"
__name__ = "stock.move"
return_equipment = fields.Boolean("Devolución", states={'invisible': If(~Eval('product_equipment'), True),
'readonly': (Eval('state').in_(['cancelled', 'done'])), }
)
@ -94,6 +115,7 @@ class ShipmentOut(metaclass=PoolMeta):
@ModelView.button
@Workflow.transition('done')
@set_employee('done_by')
@process_sale('outgoing_moves')
def done(cls, shipments):
pool = Pool()
Move = pool.get('stock.move')
@ -206,7 +228,8 @@ class ShipmentOut(metaclass=PoolMeta):
shipment.service_maintenance_initial = True
shipment.save()
else:
raise UserError(str('Por favor Primero debe Asignar un serial a todos los Equipos.'))
raise UserError(
str('Por favor Primero debe Asignar un serial a todos los Equipos.'))
class ShipmentInternal(metaclass=PoolMeta):
@ -267,9 +290,10 @@ class ShipmentOutReturn(metaclass=PoolMeta):
to_do = [s for s in shipments
if s.warehouse_storage == s.warehouse_input]
if to_do:
cls.done(to_do)
class PickingListDeliveryReport(CompanyReport):
__name__ = 'stock.shipment.out.picking_list1'