feat: Se añade funcionalidad para cambiar metodo de pago
This commit is contained in:
parent
dcd88381ee
commit
7bd47838b2
@ -21,6 +21,7 @@ def register():
|
|||||||
device.SaleDeviceStatementJournal,
|
device.SaleDeviceStatementJournal,
|
||||||
sale.Sale,
|
sale.Sale,
|
||||||
sale.SalePaymentForm,
|
sale.SalePaymentForm,
|
||||||
|
sale.ChangePaymentMethodForm,
|
||||||
statement.OpenStatementStart,
|
statement.OpenStatementStart,
|
||||||
statement.OpenStatementDone,
|
statement.OpenStatementDone,
|
||||||
statement.CloseStatementStart,
|
statement.CloseStatementStart,
|
||||||
@ -29,6 +30,7 @@ def register():
|
|||||||
module='sale_payment', type_='model')
|
module='sale_payment', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
sale.WizardSalePayment,
|
sale.WizardSalePayment,
|
||||||
|
sale.ChangePaymentMethod,
|
||||||
sale.WizardSaleReconcile,
|
sale.WizardSaleReconcile,
|
||||||
statement.OpenStatement,
|
statement.OpenStatement,
|
||||||
statement.CloseStatement,
|
statement.CloseStatement,
|
||||||
|
63
sale.py
63
sale.py
@ -41,6 +41,7 @@ class Sale(metaclass=PoolMeta):
|
|||||||
'invisible': Eval('state') == 'done',
|
'invisible': Eval('state') == 'done',
|
||||||
'readonly': Not(Bool(Eval('lines'))),
|
'readonly': Not(Bool(Eval('lines'))),
|
||||||
},
|
},
|
||||||
|
'wizard_change_payment_method': {},
|
||||||
})
|
})
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -179,6 +180,11 @@ class Sale(metaclass=PoolMeta):
|
|||||||
def wizard_sale_payment(cls, sales):
|
def wizard_sale_payment(cls, sales):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@ModelView.button_action('sale_payment.wizard_sale_change_payment_method')
|
||||||
|
def wizard_change_payment_method(cls, sales):
|
||||||
|
pass
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def copy(cls, sales, default=None):
|
def copy(cls, sales, default=None):
|
||||||
if default is None:
|
if default is None:
|
||||||
@ -187,6 +193,63 @@ class Sale(metaclass=PoolMeta):
|
|||||||
return super(Sale, cls).copy(sales, default)
|
return super(Sale, cls).copy(sales, default)
|
||||||
|
|
||||||
|
|
||||||
|
class ChangePaymentMethodForm(ModelView):
|
||||||
|
'Change Payments Method form'
|
||||||
|
__name__ = 'sale.change_payment_method.form'
|
||||||
|
sale = fields.Many2One('sale.sale', "Sale", required=True)
|
||||||
|
statement = fields.Many2One('account.statement', 'Statement Journal',
|
||||||
|
domain=[
|
||||||
|
('id', 'in', Eval('statements', [])),
|
||||||
|
],
|
||||||
|
depends=['journals'], required=True)
|
||||||
|
statements = fields.One2Many('account.statement', None,
|
||||||
|
'Allowed Statement', readonly=True)
|
||||||
|
payment = fields.Many2One(
|
||||||
|
'account.statement.line', "Payment", required=True,
|
||||||
|
domain=[('sale.id', '=', Eval('sale'))])
|
||||||
|
|
||||||
|
|
||||||
|
class ChangePaymentMethod(Wizard):
|
||||||
|
'Change Payments Method for the sale'
|
||||||
|
__name__ = 'sale.change_payment_method'
|
||||||
|
start = StateView('sale.change_payment_method.form',
|
||||||
|
'sale_payment.sale_change_payment_method_view_form', [
|
||||||
|
Button('Cancel', 'end', 'tryton-cancel'),
|
||||||
|
Button('Modify', 'modify_payments_', 'tryton-ok',
|
||||||
|
default=True),])
|
||||||
|
|
||||||
|
modify_payments_ = StateTransition()
|
||||||
|
|
||||||
|
def default_start(self, fields):
|
||||||
|
pool = Pool()
|
||||||
|
Sale = pool.get('sale.sale')
|
||||||
|
User = pool.get('res.user')
|
||||||
|
Statement = pool.get('account.statement')
|
||||||
|
sale = Sale(Transaction().context['active_id'])
|
||||||
|
user = User(Transaction().user)
|
||||||
|
device = user.sale_device
|
||||||
|
|
||||||
|
if device:
|
||||||
|
journals = [j.id for j in device.journals]
|
||||||
|
draft_statements = Statement.search([
|
||||||
|
('journal', 'in', journals),
|
||||||
|
('state', '=', 'draft'),
|
||||||
|
], order=[
|
||||||
|
('create_date', 'ASC'),
|
||||||
|
])
|
||||||
|
|
||||||
|
return {
|
||||||
|
'sale': sale.id,
|
||||||
|
'statements': [statement.id for statement in draft_statements],
|
||||||
|
}
|
||||||
|
|
||||||
|
def transition_modify_payments_(self):
|
||||||
|
self.start.payment.statement = self.start.statement.id
|
||||||
|
self.start.payment.save()
|
||||||
|
|
||||||
|
return 'end'
|
||||||
|
|
||||||
|
|
||||||
class SalePaymentForm(ModelView):
|
class SalePaymentForm(ModelView):
|
||||||
'Sale Payment Form'
|
'Sale Payment Form'
|
||||||
__name__ = 'sale.payment.form'
|
__name__ = 'sale.payment.form'
|
||||||
|
16
sale.xml
16
sale.xml
@ -31,6 +31,16 @@ copyright notices and license terms. -->
|
|||||||
<field name="name">sale_payment_form</field>
|
<field name="name">sale_payment_form</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.action.wizard" id="wizard_sale_change_payment_method">
|
||||||
|
<field name="name">Change Payment Method</field>
|
||||||
|
<field name="wiz_name">sale.change_payment_method</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.ui.view" id="sale_change_payment_method_view_form">
|
||||||
|
<field name="model">sale.change_payment_method.form</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">change_payment_method_form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record model="ir.action.wizard" id="act_sale_reconcile">
|
<record model="ir.action.wizard" id="act_sale_reconcile">
|
||||||
<field name="name">Reconcile Sales</field>
|
<field name="name">Reconcile Sales</field>
|
||||||
<field name="wiz_name">sale.reconcile</field>
|
<field name="wiz_name">sale.reconcile</field>
|
||||||
@ -43,6 +53,12 @@ copyright notices and license terms. -->
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- buttons -->
|
<!-- buttons -->
|
||||||
|
<record model="ir.model.button" id="sale_change_payment_method_wizard_button">
|
||||||
|
<field name="name">wizard_change_payment_method</field>
|
||||||
|
<field name="string">Change Payment Method</field>
|
||||||
|
<field name="model" search="[('model', '=', 'sale.sale')]"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record model="ir.model.button" id="sale_payment_wizard_button">
|
<record model="ir.model.button" id="sale_payment_wizard_button">
|
||||||
<field name="name">wizard_sale_payment</field>
|
<field name="name">wizard_sale_payment</field>
|
||||||
<field name="string">Pay</field>
|
<field name="string">Pay</field>
|
||||||
|
@ -5,6 +5,7 @@ copyright notices and license terms. -->
|
|||||||
<data>
|
<data>
|
||||||
<xpath expr="/form/group/button[@name='process']" position="after">
|
<xpath expr="/form/group/button[@name='process']" position="after">
|
||||||
<button name="wizard_sale_payment" icon="tryton-forward"/>
|
<button name="wizard_sale_payment" icon="tryton-forward"/>
|
||||||
|
<button name="wizard_change_payment_method" icon="tryton-forward"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="/form/notebook/page[@id='other']" position="after">
|
<xpath expr="/form/notebook/page[@id='other']" position="after">
|
||||||
<page string="Payments" col="4" id="payments">
|
<page string="Payments" col="4" id="payments">
|
||||||
|
Loading…
Reference in New Issue
Block a user