add sale_device field on sale, and used on payment wizard

This commit is contained in:
?ngel ?lvarez 2014-11-21 12:28:58 +01:00
parent 2da4695718
commit ae383a3399
6 changed files with 36 additions and 56 deletions

View File

@ -235,6 +235,10 @@ msgctxt "field:sale.sale,residual_amount:"
msgid "Residual Amount"
msgstr "Pendent"
msgctxt "field:sale.sale,sale_device:"
msgid "Sale Device"
msgstr "Terminal de venda"
msgctxt "field:sale.sale,self_pick_up:"
msgid "Self Pick Up"
msgstr "Auto-recollida"
@ -267,34 +271,10 @@ msgctxt "field:sale_pos.add_product_form,id:"
msgid "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:"
msgid "Sale"
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:"
msgid ""
"The goods are picked up by the customer before the sale, so no shipment is "

View File

@ -235,6 +235,10 @@ msgctxt "field:sale.sale,residual_amount:"
msgid "Residual Amount"
msgstr "Pendiente"
msgctxt "field:sale.sale,sale_device:"
msgid "Sale Device"
msgstr "Terminal de venta"
msgctxt "field:sale.sale,self_pick_up:"
msgid "Self Pick Up"
msgstr "Autorecogida"
@ -267,34 +271,10 @@ msgctxt "field:sale_pos.add_product_form,id:"
msgid "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:"
msgid "Sale"
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:"
msgid ""
"The goods are picked up by the customer before the sale, so no shipment is "

23
sale.py
View File

@ -10,7 +10,9 @@ from trytond.transaction import Transaction
from trytond.wizard import Wizard, StateView, StateTransition, Button
__all__ = ['Sale', 'SalePaymentForm', 'WizardSalePayment', 'WizardSaleReconcile']
__all__ = ['Sale', 'SalePaymentForm', 'WizardSalePayment',
'WizardSaleReconcile']
__metaclass__ = PoolMeta
@ -21,6 +23,10 @@ class Sale:
'get_paid_amount')
residual_amount = fields.Function(fields.Numeric('Residual Amount',
readonly=True), 'get_residual_amount')
sale_device = fields.Many2One('sale.device', 'Sale Device',
domain=[('shop', '=', Eval('shop'))],
depends=['shop']
)
@classmethod
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
def get_paid_amount(cls, sales, 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')
sale = Sale(Transaction().context['active_id'])
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')
return {
'journal': user.sale_device.journal.id
if user.sale_device.journal else None,
'journals': [j.id for j in user.sale_device.journals],
'journal': sale_device.journal.id
if sale_device.journal else None,
'journals': [j.id for j in sale_device.journals],
'payment_amount': sale.total_amount - sale.paid_amount
if sale.paid_amount else sale.total_amount,
'currency_digits': sale.currency_digits,

View File

@ -4,7 +4,7 @@ depends:
account_statement
sale_shop
xml:
sale.xml
device.xml
user.xml
sale.xml
statement.xml
user.xml

View File

@ -25,4 +25,11 @@ copyright notices and license terms. -->
<field name="residual_amount"/>
</page>
</xpath>
<xpath
expr="/form/notebook/page[@id='other']/field[@name='shop']"
position="after">
<label name="sale_device"/>
<field name="sale_device"/>
</xpath>
</data>

View File

@ -7,6 +7,6 @@ copyright notices and license terms. -->
expr="/form/notebook/page[@id=&quot;preferences&quot;]/field[@name=&quot;shop&quot;]"
position="after">
<label name="sale_device"/>
<field name="sale_device" widget="selection"/>
<field name="sale_device"/>
</xpath>
</data>