From e3a28836abc2a8203f8a5b3bf70ce41c32c7b65a Mon Sep 17 00:00:00 2001 From: Ludovic CHEVALIER Date: Tue, 12 May 2020 22:08:46 +0200 Subject: [PATCH] [REPORT] ~pos.receipt: client name and mobile --- __init__.py | 4 +- i18n/bikecoop_l10n_fr.pot | 27 +++- i18n/fr.po | 42 ++++-- report/__init__.py | 3 + report/pos_receipt.py | 58 ++++++++ report/pos_receipt_bikecoop_l10n_fr.rml | 181 ++++++++++++++++++++++++ wizard/__init__.py | 3 + wizard/pos_receipt.py | 25 ++++ 8 files changed, 328 insertions(+), 15 deletions(-) create mode 100644 report/__init__.py create mode 100644 report/pos_receipt.py create mode 100644 report/pos_receipt_bikecoop_l10n_fr.rml create mode 100644 wizard/__init__.py create mode 100644 wizard/pos_receipt.py diff --git a/__init__.py b/__init__.py index 17dca1b..ebfe3fa 100644 --- a/__init__.py +++ b/__init__.py @@ -2,7 +2,7 @@ ############################################################################## # # bikecoop l10n fr module for OpenERP, French localisation module for bike coop' -# Copyright (C) 2012-2016 L'Heureux Cyclage () +# Copyright (C) 2012-2020 L'Heureux Cyclage () # # This file is a part of bikecoop_l10n_fr # @@ -22,5 +22,7 @@ ############################################################################## import bikecoop +import report +import wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/i18n/bikecoop_l10n_fr.pot b/i18n/bikecoop_l10n_fr.pot index 444b987..a003402 100644 --- a/i18n/bikecoop_l10n_fr.pot +++ b/i18n/bikecoop_l10n_fr.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: OpenERP Server 7.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-09-27 09:20+0000\n" -"PO-Revision-Date: 2015-09-27 09:20+0000\n" +"POT-Creation-Date: 2020-05-12 15:41+0000\n" +"PO-Revision-Date: 2020-05-12 15:41+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -40,6 +40,11 @@ msgstr "" msgid "Membership main informations" msgstr "" +#. module: bikecoop_l10n_fr +#: model:res.groups,name:bikecoop_l10n_fr.make_invisible +msgid "Invisible" +msgstr "" + #. module: bikecoop_l10n_fr #: view:res.partner:0 msgid "Associate members" @@ -107,6 +112,12 @@ msgstr "" msgid "Associate member" msgstr "" +#. module: bikecoop_l10n_fr +#: code:addons/bikecoop_l10n_fr/point_of_sale.py:41 +#, python-format +msgid "Your ending balance is too different from the theoretical cash closing (%.2f), the maximum allowed is: %.2f. Want you really close this cash statement?" +msgstr "" + #. module: bikecoop_l10n_fr #: view:res.partner:0 msgid "CITY" @@ -119,12 +130,13 @@ msgstr "" #. module: bikecoop_l10n_fr #: view:res.partner:0 -msgid "Other, Female or Male" +msgid "All bikecoop members" msgstr "" #. module: bikecoop_l10n_fr -#: view:res.partner:0 -msgid "All bikecoop members" +#: code:addons/bikecoop_l10n_fr/point_of_sale.py:40 +#, python-format +msgid "Warning!" msgstr "" #. module: bikecoop_l10n_fr @@ -132,6 +144,11 @@ msgstr "" msgid "Partner" msgstr "" +#. module: bikecoop_l10n_fr +#: model:ir.model,name:bikecoop_l10n_fr.model_pos_receipt +msgid "Point of sale receipt" +msgstr "" + #. module: bikecoop_l10n_fr #: view:res.partner:0 msgid "Postal address" diff --git a/i18n/fr.po b/i18n/fr.po index ea3c305..ae86eaf 100644 --- a/i18n/fr.po +++ b/i18n/fr.po @@ -6,15 +6,15 @@ msgid "" msgstr "" "Project-Id-Version: OpenERP Server 7.0alpha\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-09-27 11:21+0200\n" -"PO-Revision-Date: 2015-09-27 11:22+0200\n" +"POT-Creation-Date: 2020-05-12 15:41+0000\n" +"PO-Revision-Date: 2020-05-12 17:46+0200\n" "Last-Translator: Ludovic CHEVALIER \n" "Language-Team: \n" "Language: fr_FR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.8.4\n" +"X-Generator: Poedit 2.3\n" #. module: bikecoop_l10n_fr #: view:res.partner:0 @@ -41,6 +41,11 @@ msgstr "Rue ..." msgid "Membership main informations" msgstr "Informations principales d'adhésion" +#. module: bikecoop_l10n_fr +#: model:res.groups,name:bikecoop_l10n_fr.make_invisible +msgid "Invisible" +msgstr "Invisible" + #. module: bikecoop_l10n_fr #: view:res.partner:0 msgid "Associate members" @@ -106,6 +111,15 @@ msgstr "Adhésions" msgid "Associate member" msgstr "Membres associé-e-s" +#. module: bikecoop_l10n_fr +#: code:addons/bikecoop_l10n_fr/point_of_sale.py:41 +#, python-format +msgid "" +"Your ending balance is too different from the theoretical cash closing " +"(%.2f), the maximum allowed is: %.2f. Want you really close this cash " +"statement?" +msgstr "" + #. module: bikecoop_l10n_fr #: view:res.partner:0 msgid "CITY" @@ -116,26 +130,35 @@ msgstr "VILLE" msgid "Occupations" msgstr "Activités" -#. module: bikecoop_l10n_fr -#: view:res.partner:0 -msgid "Other, Female or Male" -msgstr "Autre, Féminin, Masculin" - #. module: bikecoop_l10n_fr #: view:res.partner:0 msgid "All bikecoop members" msgstr "Tous les membres de l'atelier" +#. module: bikecoop_l10n_fr +#: code:addons/bikecoop_l10n_fr/point_of_sale.py:40 +#, python-format +msgid "Warning!" +msgstr "Avertissement!" + #. module: bikecoop_l10n_fr #: model:ir.model,name:bikecoop_l10n_fr.model_res_partner msgid "Partner" msgstr "Partenaire" +#. module: bikecoop_l10n_fr +#: model:ir.model,name:bikecoop_l10n_fr.model_pos_receipt +msgid "Point of sale receipt" +msgstr "Reçu de l'atelier\t" + #. module: bikecoop_l10n_fr #: view:res.partner:0 msgid "Postal address" msgstr "Adresse postale" +#~ msgid "Other, Female or Male" +#~ msgstr "Autre, Féminin, Masculin" + #~ msgid "..." #~ msgstr "..." @@ -143,7 +166,8 @@ msgstr "Adresse postale" #~ msgstr "Membres associés à ce partenaire" #~ msgid "Error ! You cannot create recursive associated members." -#~ msgstr "Erreur! Vous ne pouvez pas créer de membres associés de façon récursive." +#~ msgstr "" +#~ "Erreur! Vous ne pouvez pas créer de membres associés de façon récursive." #~ msgid "Bikecoop members" #~ msgstr "Membres de l'atelier" diff --git a/report/__init__.py b/report/__init__.py new file mode 100644 index 0000000..e201b0b --- /dev/null +++ b/report/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +import pos_receipt diff --git a/report/pos_receipt.py b/report/pos_receipt.py new file mode 100644 index 0000000..8379027 --- /dev/null +++ b/report/pos_receipt.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +import time +from openerp.report import report_sxw +from openerp import pooler + +def titlize(journal_name): + words = journal_name.split() + while words.pop() != 'journal': + continue + return ' '.join(words) + +class order(report_sxw.rml_parse): + + def __init__(self, cr, uid, name, context): + super(order, self).__init__(cr, uid, name, context=context) + + user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context) + partner = user.company_id.partner_id + + self.localcontext.update({ + 'time': time, + 'disc': self.discount, + 'net': self.netamount, + 'get_journal_amt': self._get_journal_amt, + 'address': partner or False, + 'titlize': titlize + }) + + def netamount(self, order_line_id): + sql = 'select (qty*price_unit) as net_price from pos_order_line where id = %s' + self.cr.execute(sql, (order_line_id,)) + res = self.cr.fetchone() + return res[0] + + def discount(self, order_id): + sql = 'select discount, price_unit, qty from pos_order_line where order_id = %s ' + self.cr.execute(sql, (order_id,)) + res = self.cr.fetchall() + dsum = 0 + for line in res: + if line[0] != 0: + dsum = dsum +(line[2] * (line[0]*line[1]/100)) + return dsum + + def _get_journal_amt(self, order_id): + data={} + sql = """ select aj.name,absl.amount as amt from account_bank_statement as abs + LEFT JOIN account_bank_statement_line as absl ON abs.id = absl.statement_id + LEFT JOIN account_journal as aj ON aj.id = abs.journal_id + WHERE absl.pos_statement_id =%d"""%(order_id) + self.cr.execute(sql) + data = self.cr.dictfetchall() + return data + + + +report_sxw.report_sxw('report.bikecoop_l10n_fr.receipt', 'pos.order', 'addons/bikecoop_l10n_fr/report/pos_receipt_bikecoop_l10n_fr.rml', parser=order, header=False) diff --git a/report/pos_receipt_bikecoop_l10n_fr.rml b/report/pos_receipt_bikecoop_l10n_fr.rml new file mode 100644 index 0000000..67f1667 --- /dev/null +++ b/report/pos_receipt_bikecoop_l10n_fr.rml @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[ repeatIn(objects,'o') ]] + [[ o.note ]] + + + + [[o.user_id.company_id.name]] + [[ address and display_address(address)]] + Tél : [[ address and address.phone ]] + SIRET : [[o.user_id.company_id.siret]] + Atelier : [[ o.shop_id.name ]] + Date : [[ o.date_order ]] + + + + Bénéficiaire + [[ o.partner_id.name ]] + Portable: [[ o.partner_id.mobile ]] + + + + + + + + + + [[ o.name ]] + + + + Description + + + Qté + + + Prix + + + + + [[ repeatIn(o.lines,'line') ]] + [[ line.product_id.name ]] + + With a [[ line and line.discount == 0.0 and removeParentNode('font') ]] ([[ '%.2f' % line.discount ]]) % discount. + + + + + + + [[o.state=='cancel' and o.statement_ids and '-' or '']][['%.f' % line.qty ]] + + + [[o.state=='cancel' and o.statement_ids and '-' or '']][[ formatLang(net(line.id), currency_obj=company.currency_id) ]] [[ line and line.discount == 0.0 and removeParentNode('font') ]] ([[ formatLang(line.discount, currency_obj=company.currency_id) ]]) + + + + + + + Taxes : + + + [[o.state=='cancel' and o.statement_ids and '-' or '']][[formatLang(o.amount_tax, currency_obj=company.currency_id)]] + + + + + + + Total : + + + [[o.state=='cancel' and o.statement_ids and '-' or '']][[formatLang(o.amount_total, currency_obj=company.currency_id)]] + + + + + + + Moyen(s) de paiement + + + + + + + + Montant + + + + + [[ repeatIn(get_journal_amt(o),'d') ]] + [[ d['name'] ]] + + + + + + + + [[ formatLang(d['amt'] or 0, currency_obj=company.currency_id) ]] + + + + + diff --git a/wizard/__init__.py b/wizard/__init__.py new file mode 100644 index 0000000..e201b0b --- /dev/null +++ b/wizard/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +import pos_receipt diff --git a/wizard/pos_receipt.py b/wizard/pos_receipt.py new file mode 100644 index 0000000..a1e0fc5 --- /dev/null +++ b/wizard/pos_receipt.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +from openerp.osv import orm + + +class print_report(orm.Model): + _inherit = 'pos.receipt' + + def print_report(self, cr, uid, ids, context=None): + """ + To get the date and print the report + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param context: A standard dictionary + @return : retrun report + """ + if context is None: + context = {} + datas = {'ids': context.get('active_ids', [])} + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'bikecoop_l10n_fr.receipt', + 'datas': datas, + } -- 2.20.1