trytond-patches/sale_payment.diff

222 lines
7.3 KiB
Diff

diff -r 4f3d2a123b76 device.py
--- a/trytond/trytond/modules/sale_payment/device.py Tue Nov 04 13:49:33 2014 +0100
+++ b/trytond/trytond/modules/sale_payment/device.py Tue May 12 16:07:37 2015 +0200
@@ -53,6 +53,14 @@
def search_company(cls, name, clause):
return [('shop.%s' % name,) + tuple(clause[1:])]
+ @classmethod
+ def copy(cls, reports, default=None):
+ if default is None:
+ default = {}
+ default = default.copy()
+ default['users'] = None
+ return super(SaleDevice, cls).copy(reports, default=default)
+
class SaleDeviceStatementJournal(ModelSQL):
'Sale Device - Statement Journal'
diff -r 4f3d2a123b76 locale/ca_ES.po
--- a/trytond/trytond/modules/sale_payment/locale/ca_ES.po Tue Nov 04 13:49:33 2014 +0100
+++ b/trytond/trytond/modules/sale_payment/locale/ca_ES.po Tue May 12 16:07:37 2015 +0200
@@ -235,6 +235,10 @@
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 @@
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 "
diff -r 4f3d2a123b76 locale/es_ES.po
--- a/trytond/trytond/modules/sale_payment/locale/es_ES.po Tue Nov 04 13:49:33 2014 +0100
+++ b/trytond/trytond/modules/sale_payment/locale/es_ES.po Tue May 12 16:07:37 2015 +0200
@@ -235,6 +235,10 @@
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 @@
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 "
diff -r 4f3d2a123b76 sale.py
--- a/trytond/trytond/modules/sale_payment/sale.py Tue Nov 04 13:49:33 2014 +0100
+++ b/trytond/trytond/modules/sale_payment/sale.py Tue May 12 16:07:37 2015 +0200
@@ -8,6 +8,7 @@
from trytond.pyson import Bool, Eval, Not
from trytond.transaction import Transaction
from trytond.wizard import Wizard, StateView, StateTransition, Button
+from sql.aggregate import Sum
__all__ = ['Sale', 'SalePaymentForm', 'WizardSalePayment', 'WizardSaleReconcile']
@@ -18,9 +19,13 @@
__name__ = 'sale.sale'
payments = fields.One2Many('account.statement.line', 'sale', 'Payments')
paid_amount = fields.Function(fields.Numeric('Paid Amount', readonly=True),
- 'get_paid_amount')
+ 'get_paid_amount', searcher='search_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):
@@ -42,6 +47,21 @@
return result
@classmethod
+ def search_paid_amount(cls, name, clause):
+ Sale = Pool().get('sale.sale')
+ StatementLine = Pool().get('account.statement.line')
+ sale = Sale.__table__()
+ line = StatementLine.__table__()
+
+ Operator = fields.SQL_OPERATORS[clause[1]]
+ join = sale.join(line, condition=(sale.id == line.sale))
+ query = join.select(
+ sale.id,
+ group_by=(sale.id),
+ having=Operator(Sum(line.amount), Decimal(clause[2] or 0)))
+ return [('id', 'in', query)]
+
+ @classmethod
def get_residual_amount(cls, sales, names):
return {
n: {s.id: s.total_amount - s.paid_amount for s in sales}
@@ -109,12 +129,13 @@
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,
diff -r 4f3d2a123b76 tryton.cfg
--- a/trytond/trytond/modules/sale_payment/tryton.cfg Tue Nov 04 13:49:33 2014 +0100
+++ b/trytond/trytond/modules/sale_payment/tryton.cfg Tue May 12 16:07:37 2015 +0200
@@ -4,7 +4,7 @@
account_statement
sale_shop
xml:
+ device.xml
sale.xml
- device.xml
+ statement.xml
user.xml
- statement.xml
diff -r 4f3d2a123b76 view/sale_form.xml
--- a/trytond/trytond/modules/sale_payment/view/sale_form.xml Tue Nov 04 13:49:33 2014 +0100
+++ b/trytond/trytond/modules/sale_payment/view/sale_form.xml Tue May 12 16:07:37 2015 +0200
@@ -25,4 +25,11 @@
<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>
diff -r 4f3d2a123b76 view/user_form.xml
--- a/trytond/trytond/modules/sale_payment/view/user_form.xml Tue Nov 04 13:49:33 2014 +0100
+++ b/trytond/trytond/modules/sale_payment/view/user_form.xml Tue May 12 16:07:37 2015 +0200
@@ -7,6 +7,6 @@
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>