Se habilita nuevamente el Wizard Compra a un Click, y se hace compatible a Raise-Gettext los UserError
This commit is contained in:
parent
1bd3396ab1
commit
c062dc9bce
|
@ -11,5 +11,8 @@ def register():
|
|||
Configuration,
|
||||
Purchase,
|
||||
module='one_click_for_purchase', type_='model')
|
||||
Pool.register(
|
||||
OneClickForPurchase,
|
||||
module='one_click_for_purchase', type_='wizard')
|
||||
Pool.register(
|
||||
module='one_click_for_purchase', type_='report')
|
||||
|
|
30
purchase.py
30
purchase.py
|
@ -11,12 +11,15 @@ from trytond.modules.company.model import (
|
|||
from trytond.model.workflow import Workflow
|
||||
from trytond.modules.account.tax import TaxableMixin
|
||||
from trytond.pyson import Eval
|
||||
from .exceptions import ErroresGenerales
|
||||
from trytond.i18n import gettext
|
||||
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
__all__ = ['Configuration','Purchase']
|
||||
__all__ = ['OneClickForPurchase','Configuration','Purchase']
|
||||
|
||||
|
||||
class Configuration(ModelSingleton, ModelSQL, ModelView, CompanyMultiValueMixin):
|
||||
|
@ -61,13 +64,13 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin):
|
|||
if purchases:
|
||||
for purchase in purchases:
|
||||
if purchase.state != 'draft' or len(purchase.lines) < 1:
|
||||
cls.raise_user_error('La compra {p} no esta en estado Borrador o no contiene lineas'.format(p=purchase.id))
|
||||
raise ErroresGenerales(gettext('one_click_for_purchase.msg_noborrador_sinlineas').format(s=purchase.number))
|
||||
return
|
||||
if not purchase.invoice_address:
|
||||
cls.raise_user_error('Error: La compra {p} no tiene direccion de facturacion'.format(p=purchase.id))
|
||||
raise ErroresGenerales(gettext('one_click_for_purchase.msg_error_direccion').format(p=purchase.id))
|
||||
return
|
||||
else:
|
||||
cls.raise_user_error('Error en las compras seleccionadas')
|
||||
raise ErroresGenerales(gettext('one_click_for_purchase.msg_error_ventanas'))
|
||||
return
|
||||
|
||||
cls.set_purchase_date(purchases)#pone fecha de compra a los registros que no lo tienen
|
||||
|
@ -78,7 +81,7 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin):
|
|||
purchases = cls.browse([x.id for x in purchases])#se vuelve a leer para cargar informacion de la base de datos, verificar si es necesario.
|
||||
purchases = [x for x in purchases if (x.state == 'processing' and len(x.lines) > 0) ]
|
||||
if len(purchases) <= 0 :
|
||||
cls.raise_user_error('Fallo la finalizacion automatica de la(s) compra(s)')
|
||||
raise ErroresGenerales(gettext('one_click_for_purchase.msg_fallo_finalizacion'))
|
||||
return
|
||||
for purchase in purchases:
|
||||
invoices = purchase.invoices
|
||||
|
@ -103,3 +106,20 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin):
|
|||
Move.do(moves)
|
||||
|
||||
|
||||
class OneClickForPurchase(Wizard):
|
||||
'''Compra en un click.
|
||||
|
||||
Procesa una compra en estado de borrador llevandola al estado "procesada",
|
||||
creando las Facturas y Movimientos de Stock, además contabiliza la factura
|
||||
y cambia el movimiento de stock de la entrada al almacenamiento y finaliza los movimientos de stock.
|
||||
'''
|
||||
|
||||
__name__ = 'purchase.one_click_for_purchase'
|
||||
|
||||
start = StateTransition()
|
||||
|
||||
def transition_start(self):
|
||||
Purchase = Pool().get('purchase.purchase')
|
||||
purchases = Purchase.browse(Transaction().context['active_ids'])
|
||||
Purchase.draft_to_done(purchases)
|
||||
return 'end'
|
||||
|
|
16
purchase.xml
16
purchase.xml
|
@ -15,11 +15,21 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="model">purchase.purchase</field>
|
||||
<field name="inherit" ref="purchase.purchase_view_form"/>
|
||||
<field name="name">purchase_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="purchase_configuration_view_form">
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="wizard_one_click_purchase">
|
||||
<field name="name">Compra en Un click</field>
|
||||
<field name="wiz_name">purchase.one_click_for_purchase</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword"
|
||||
id="act_one_click_purchase_keyword1">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">purchase.purchase,-1</field>
|
||||
<field name="action" ref="wizard_one_click_purchase"/>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="purchase_configuration_view_form">
|
||||
<field name="model">purchase.configuration</field>
|
||||
<field name="inherit" ref="purchase.purchase_configuration_view_form"/>
|
||||
<field name="name">purchase_configuration_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
</tryton>
|
|
@ -5,3 +5,4 @@ depends:
|
|||
purchase
|
||||
xml:
|
||||
purchase.xml
|
||||
message.xml
|
||||
|
|
Loading…
Reference in New Issue