add sale_device field on sale, and used on payment wizard
This commit is contained in:
parent
2da4695718
commit
ae383a3399
@ -235,6 +235,10 @@ msgctxt "field:sale.sale,residual_amount:"
|
|||||||
msgid "Residual Amount"
|
msgid "Residual Amount"
|
||||||
msgstr "Pendent"
|
msgstr "Pendent"
|
||||||
|
|
||||||
|
msgctxt "field:sale.sale,sale_device:"
|
||||||
|
msgid "Sale Device"
|
||||||
|
msgstr "Terminal de venda"
|
||||||
|
|
||||||
msgctxt "field:sale.sale,self_pick_up:"
|
msgctxt "field:sale.sale,self_pick_up:"
|
||||||
msgid "Self Pick Up"
|
msgid "Self Pick Up"
|
||||||
msgstr "Auto-recollida"
|
msgstr "Auto-recollida"
|
||||||
@ -267,34 +271,10 @@ msgctxt "field:sale_pos.add_product_form,id:"
|
|||||||
msgid "ID"
|
msgid "ID"
|
||||||
msgstr "ID"
|
msgstr "ID"
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,product:"
|
|
||||||
msgid "Product"
|
|
||||||
msgstr "Producte"
|
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,product_uom_category:"
|
|
||||||
msgid "Product Uom Category"
|
|
||||||
msgstr "Categoria UdM del producte"
|
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,quantity:"
|
|
||||||
msgid "Quantity"
|
|
||||||
msgstr "Quantitat"
|
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,sale:"
|
msgctxt "field:sale_pos.add_product_form,sale:"
|
||||||
msgid "Sale"
|
msgid "Sale"
|
||||||
msgstr "Venda"
|
msgstr "Venda"
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,unit:"
|
|
||||||
msgid "Unit"
|
|
||||||
msgstr "Unitat"
|
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,unit_digits:"
|
|
||||||
msgid "Unit Digits"
|
|
||||||
msgstr "Dígits unitat"
|
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,unit_price:"
|
|
||||||
msgid "Unit price"
|
|
||||||
msgstr "Preu unitat"
|
|
||||||
|
|
||||||
msgctxt "help:sale.sale,self_pick_up:"
|
msgctxt "help:sale.sale,self_pick_up:"
|
||||||
msgid ""
|
msgid ""
|
||||||
"The goods are picked up by the customer before the sale, so no shipment is "
|
"The goods are picked up by the customer before the sale, so no shipment is "
|
||||||
|
@ -235,6 +235,10 @@ msgctxt "field:sale.sale,residual_amount:"
|
|||||||
msgid "Residual Amount"
|
msgid "Residual Amount"
|
||||||
msgstr "Pendiente"
|
msgstr "Pendiente"
|
||||||
|
|
||||||
|
msgctxt "field:sale.sale,sale_device:"
|
||||||
|
msgid "Sale Device"
|
||||||
|
msgstr "Terminal de venta"
|
||||||
|
|
||||||
msgctxt "field:sale.sale,self_pick_up:"
|
msgctxt "field:sale.sale,self_pick_up:"
|
||||||
msgid "Self Pick Up"
|
msgid "Self Pick Up"
|
||||||
msgstr "Autorecogida"
|
msgstr "Autorecogida"
|
||||||
@ -267,34 +271,10 @@ msgctxt "field:sale_pos.add_product_form,id:"
|
|||||||
msgid "ID"
|
msgid "ID"
|
||||||
msgstr "ID"
|
msgstr "ID"
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,product:"
|
|
||||||
msgid "Product"
|
|
||||||
msgstr "Producto"
|
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,product_uom_category:"
|
|
||||||
msgid "Product Uom Category"
|
|
||||||
msgstr "Categoría UdM del producto"
|
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,quantity:"
|
|
||||||
msgid "Quantity"
|
|
||||||
msgstr "Cantidad"
|
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,sale:"
|
msgctxt "field:sale_pos.add_product_form,sale:"
|
||||||
msgid "Sale"
|
msgid "Sale"
|
||||||
msgstr "Venta"
|
msgstr "Venta"
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,unit:"
|
|
||||||
msgid "Unit"
|
|
||||||
msgstr "Unidad"
|
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,unit_digits:"
|
|
||||||
msgid "Unit Digits"
|
|
||||||
msgstr "Dígitos unidad"
|
|
||||||
|
|
||||||
msgctxt "field:sale_pos.add_product_form,unit_price:"
|
|
||||||
msgid "Unit price"
|
|
||||||
msgstr "Precio unidad"
|
|
||||||
|
|
||||||
msgctxt "help:sale.sale,self_pick_up:"
|
msgctxt "help:sale.sale,self_pick_up:"
|
||||||
msgid ""
|
msgid ""
|
||||||
"The goods are picked up by the customer before the sale, so no shipment is "
|
"The goods are picked up by the customer before the sale, so no shipment is "
|
||||||
|
23
sale.py
23
sale.py
@ -10,7 +10,9 @@ from trytond.transaction import Transaction
|
|||||||
from trytond.wizard import Wizard, StateView, StateTransition, Button
|
from trytond.wizard import Wizard, StateView, StateTransition, Button
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['Sale', 'SalePaymentForm', 'WizardSalePayment', 'WizardSaleReconcile']
|
__all__ = ['Sale', 'SalePaymentForm', 'WizardSalePayment',
|
||||||
|
'WizardSaleReconcile']
|
||||||
|
|
||||||
__metaclass__ = PoolMeta
|
__metaclass__ = PoolMeta
|
||||||
|
|
||||||
|
|
||||||
@ -21,6 +23,10 @@ class Sale:
|
|||||||
'get_paid_amount')
|
'get_paid_amount')
|
||||||
residual_amount = fields.Function(fields.Numeric('Residual Amount',
|
residual_amount = fields.Function(fields.Numeric('Residual Amount',
|
||||||
readonly=True), 'get_residual_amount')
|
readonly=True), 'get_residual_amount')
|
||||||
|
sale_device = fields.Many2One('sale.device', 'Sale Device',
|
||||||
|
domain=[('shop', '=', Eval('shop'))],
|
||||||
|
depends=['shop']
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
@ -32,6 +38,12 @@ class Sale:
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_sale_device():
|
||||||
|
User = Pool().get('res.user')
|
||||||
|
user = User(Transaction().user)
|
||||||
|
return user.sale_device or None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_paid_amount(cls, sales, names):
|
def get_paid_amount(cls, sales, names):
|
||||||
result = {n: {s.id: Decimal(0) for s in sales} for n in names}
|
result = {n: {s.id: Decimal(0) for s in sales} for n in names}
|
||||||
@ -109,12 +121,13 @@ class WizardSalePayment(Wizard):
|
|||||||
User = pool.get('res.user')
|
User = pool.get('res.user')
|
||||||
sale = Sale(Transaction().context['active_id'])
|
sale = Sale(Transaction().context['active_id'])
|
||||||
user = User(Transaction().user)
|
user = User(Transaction().user)
|
||||||
if user.id != 0 and not user.sale_device:
|
sale_device = sale.sale_device or user.sale_device or False
|
||||||
|
if user.id != 0 and not sale_device:
|
||||||
self.raise_user_error('not_sale_device')
|
self.raise_user_error('not_sale_device')
|
||||||
return {
|
return {
|
||||||
'journal': user.sale_device.journal.id
|
'journal': sale_device.journal.id
|
||||||
if user.sale_device.journal else None,
|
if sale_device.journal else None,
|
||||||
'journals': [j.id for j in user.sale_device.journals],
|
'journals': [j.id for j in sale_device.journals],
|
||||||
'payment_amount': sale.total_amount - sale.paid_amount
|
'payment_amount': sale.total_amount - sale.paid_amount
|
||||||
if sale.paid_amount else sale.total_amount,
|
if sale.paid_amount else sale.total_amount,
|
||||||
'currency_digits': sale.currency_digits,
|
'currency_digits': sale.currency_digits,
|
||||||
|
@ -4,7 +4,7 @@ depends:
|
|||||||
account_statement
|
account_statement
|
||||||
sale_shop
|
sale_shop
|
||||||
xml:
|
xml:
|
||||||
sale.xml
|
|
||||||
device.xml
|
device.xml
|
||||||
user.xml
|
sale.xml
|
||||||
statement.xml
|
statement.xml
|
||||||
|
user.xml
|
||||||
|
@ -25,4 +25,11 @@ copyright notices and license terms. -->
|
|||||||
<field name="residual_amount"/>
|
<field name="residual_amount"/>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
|
<xpath
|
||||||
|
expr="/form/notebook/page[@id='other']/field[@name='shop']"
|
||||||
|
position="after">
|
||||||
|
<label name="sale_device"/>
|
||||||
|
<field name="sale_device"/>
|
||||||
|
</xpath>
|
||||||
</data>
|
</data>
|
||||||
|
@ -7,6 +7,6 @@ copyright notices and license terms. -->
|
|||||||
expr="/form/notebook/page[@id="preferences"]/field[@name="shop"]"
|
expr="/form/notebook/page[@id="preferences"]/field[@name="shop"]"
|
||||||
position="after">
|
position="after">
|
||||||
<label name="sale_device"/>
|
<label name="sale_device"/>
|
||||||
<field name="sale_device" widget="selection"/>
|
<field name="sale_device"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</data>
|
</data>
|
||||||
|
Loading…
Reference in New Issue
Block a user