From 8fc782fc9ba99e17ebde81fd94dac652e5568f41 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Tue, 8 Mar 2016 21:04:56 +0100 Subject: [PATCH 01/12] [MERGE][TACHE] 0010 - Gestion de foyer de mangeurs --- beesdoo_pos/__openerp__.py | 2 +- beesdoo_pos/models/beesdoo_pos.py | 23 ++++++++- beesdoo_pos/static/src/css/beesdoo.css | 24 +++++++++ beesdoo_pos/static/src/js/beesdoo.js | 63 +++++++++++++++++++++++- beesdoo_pos/static/src/xml/templates.xml | 26 +++++++++- beesdoo_pos/views/beesdoo_pos.xml | 2 +- 6 files changed, 135 insertions(+), 5 deletions(-) diff --git a/beesdoo_pos/__openerp__.py b/beesdoo_pos/__openerp__.py index 3753249..384275e 100644 --- a/beesdoo_pos/__openerp__.py +++ b/beesdoo_pos/__openerp__.py @@ -4,7 +4,7 @@ 'summary': """ Module that extends the pos for the beescoop - """, + """, 'description': """ Long description of module's purpose diff --git a/beesdoo_pos/models/beesdoo_pos.py b/beesdoo_pos/models/beesdoo_pos.py index 75de9e6..319bf3a 100644 --- a/beesdoo_pos/models/beesdoo_pos.py +++ b/beesdoo_pos/models/beesdoo_pos.py @@ -38,4 +38,25 @@ class BeescoopPosOrder(models.Model): return _('Cannot send the ticket, no email address found on the client') mail_template = self.env.ref("beescoop_pos.email_send_ticket") mail_template.send_mail(order.id) - return _("Ticket sent") \ No newline at end of file + return _("Ticket sent") + +class BeescoopPosPartner(models.Model): + _inherit = 'res.partner' + + def _get_eater(self): + eater1, eater2 = False, False + if self.child_eater_ids: + eater1 = self.child_eater_ids[0].name + if len(self.child_eater_ids) > 1: + eater2 = self.child_eater_ids[1].name + return eater1, eater2 + + @api.multi + def get_balance_and_eater(self): + self.ensure_one() + account_id = self.property_account_receivable_id.id + move_lines = self.env['account.move.line'].search([('account_id', '=', account_id), ('partner_id', '=', self.id)]) + credit = sum([m.credit for m in move_lines]) + debit = sum([m.debit for m in move_lines]) + eater1, eater2 = self._get_eater() + return str(round(credit - debit, 2)), eater1, eater2 diff --git a/beesdoo_pos/static/src/css/beesdoo.css b/beesdoo_pos/static/src/css/beesdoo.css index a68e1ed..4a794e4 100644 --- a/beesdoo_pos/static/src/css/beesdoo.css +++ b/beesdoo_pos/static/src/css/beesdoo.css @@ -1,4 +1,28 @@ .message-send { margin: 16px; text-align: center; +} + +.customer-information { + margin: 16px 24px 16px 24px; + font-weight: bold; + font-size: 16px; +} + +.customer-name { + font-size: 18px; +} + +.button.set-customer.decentered { + height: 108px; +} + +.customer-information-pay { + font-weight: normal; + font-size: 12px; + text-align: left; +} + +.pos .actionpad .button.pay { + height: 108px; } \ No newline at end of file diff --git a/beesdoo_pos/static/src/js/beesdoo.js b/beesdoo_pos/static/src/js/beesdoo.js index 79b6161..7d483c9 100644 --- a/beesdoo_pos/static/src/js/beesdoo.js +++ b/beesdoo_pos/static/src/js/beesdoo.js @@ -2,12 +2,23 @@ odoo.define('beescoop.pos', function (require) { "use strict"; var module = require("point_of_sale.screens"); var Model = require('web.DataModel'); + var set_customer_info = function(el_class, value, prefix) { + var el = this.$(el_class); + el.empty(); + if (prefix && value) { + value = prefix + value + } + if (value) { + el.append(value); + } + } module.ReceiptScreenWidget = module.ReceiptScreenWidget.include({ send : function() { var self = this; + var loaded = new $.Deferred(); var order = this.pos.get_order().name; - var records = new Model('pos.order').call('send_order', [order], {}); + var records = new Model('pos.order').call('send_order', [order], {}, { shadow: false, timeout: 10000}); records.then(function(result){ var el = self.$('.message-send') el.empty(); @@ -31,4 +42,54 @@ odoo.define('beescoop.pos', function (require) { this.$('.message-send').empty(); }, }) + + module.ActionpadWidget = module.ActionpadWidget.include({ + renderElement : function() { + var self = this; + var loaded = new $.Deferred(); + this._super(); + if (!this.pos.get_client()) { + return + + } + var customer_id = this.pos.get_client().id; + var res = new Model('res.partner').call('get_balance_and_eater', + [ customer_id ], undefined, { shadow: true, timeout: 1000}); + res.then(function(result) { + set_customer_info.call(self, '.customer-balance', result[0]) + set_customer_info.call(self, '.customer-delegate1', result[1], 'Eater 1: '); + set_customer_info.call(self, '.customer-delegate2', result[2], 'Eater 2: '); + }, function(err) { + loaded.reject(err); + }); + }, + }); + + module.PaymentScreenWidget.include({ + render_customer_info : function() { + var self = this; + var loaded = new $.Deferred(); + if (!this.pos.get_client()) { + return + } + var customer_id = this.pos.get_client().id; + var res = new Model('res.partner').call('get_balance_and_eater', [ customer_id ], undefined, { shadow: true, timeout: 1000}); + res.then(function(result) { + set_customer_info.call(self, '.customer-name', self.pos.get_client().name); + set_customer_info.call(self, '.customer-balance', result[0]); + set_customer_info.call(self, '.customer-delegate1', result[1], 'Eater 1: '); + set_customer_info.call(self, '.customer-delegate2', result[2], 'Eater 2: '); + }, function(err) { + loaded.reject(err); + }); + }, + renderElement : function() { + this._super(); + this.render_customer_info(); + }, + customer_changed : function() { + this._super(); + this.render_customer_info(); + }, + }); }); \ No newline at end of file diff --git a/beesdoo_pos/static/src/xml/templates.xml b/beesdoo_pos/static/src/xml/templates.xml index e9b3391..2eda871 100644 --- a/beesdoo_pos/static/src/xml/templates.xml +++ b/beesdoo_pos/static/src/xml/templates.xml @@ -6,8 +6,32 @@ Send Receipt By Mail
-
+ + + + +
+ Balance: € +
+
+
+
+
+
+ + + + +
+
+ Balance:
+
+
+
+
+
+
\ No newline at end of file diff --git a/beesdoo_pos/views/beesdoo_pos.xml b/beesdoo_pos/views/beesdoo_pos.xml index 2f8397e..0069bb9 100644 --- a/beesdoo_pos/views/beesdoo_pos.xml +++ b/beesdoo_pos/views/beesdoo_pos.xml @@ -23,4 +23,4 @@ - \ No newline at end of file + From f1b6599b60ea54495d865da26d61a6bb8d70cb47 Mon Sep 17 00:00:00 2001 From: jmf Date: Fri, 20 May 2016 23:34:32 +0200 Subject: [PATCH 02/12] [ADD] Added max_shipping_date, responsible person --- beesdoo_inventory/__init__.py | 2 ++ beesdoo_inventory/__openerp__.py | 31 ++++++++++++++++++++++++++++ beesdoo_inventory/models/__init__.py | 2 ++ beesdoo_inventory/models/stock.py | 8 +++++++ beesdoo_inventory/views/stock.xml | 18 ++++++++++++++++ 5 files changed, 61 insertions(+) create mode 100644 beesdoo_inventory/__init__.py create mode 100644 beesdoo_inventory/__openerp__.py create mode 100644 beesdoo_inventory/models/__init__.py create mode 100644 beesdoo_inventory/models/stock.py create mode 100644 beesdoo_inventory/views/stock.xml diff --git a/beesdoo_inventory/__init__.py b/beesdoo_inventory/__init__.py new file mode 100644 index 0000000..0f7cb6b --- /dev/null +++ b/beesdoo_inventory/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import models \ No newline at end of file diff --git a/beesdoo_inventory/__openerp__.py b/beesdoo_inventory/__openerp__.py new file mode 100644 index 0000000..03e6d33 --- /dev/null +++ b/beesdoo_inventory/__openerp__.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +{ + 'name': "beesdoo_inventory", + + 'summary': """ + Modification of inventory data for the needs of beescoop + - SOO24 - Bon de livraison""", + + 'description': """ + + """, + + 'author': "Beescoop - Cellule IT", + 'website': "https://github.com/beescoop/Obeesdoo", + + # Categories can be used to filter modules in modules listing + # Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml + # for the full list + 'category': 'Sales Management', + 'version': '0.1', + + # any module necessary for this one to work correctly + 'depends': ['delivery'], + + # always loaded + 'data': [ + 'views/stock.xml' ], + + # only loaded in demonstration mode + 'demo': [], +} \ No newline at end of file diff --git a/beesdoo_inventory/models/__init__.py b/beesdoo_inventory/models/__init__.py new file mode 100644 index 0000000..9d94072 --- /dev/null +++ b/beesdoo_inventory/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import stock \ No newline at end of file diff --git a/beesdoo_inventory/models/stock.py b/beesdoo_inventory/models/stock.py new file mode 100644 index 0000000..562f6c9 --- /dev/null +++ b/beesdoo_inventory/models/stock.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +from openerp import models, fields, api, _ + +class StockPicking(models.Model): + _inherit = 'stock.picking' + + max_shipping_date = fields.Datetime("End Shipping Date") + responsible = fields.Many2one("res.partner", string="Responsible Person") diff --git a/beesdoo_inventory/views/stock.xml b/beesdoo_inventory/views/stock.xml new file mode 100644 index 0000000..bdd0877 --- /dev/null +++ b/beesdoo_inventory/views/stock.xml @@ -0,0 +1,18 @@ + + + + + beesdoo.stock.form.view + stock.picking + + + + + + + + + + + + \ No newline at end of file From 34f334d64e585c27f200eb51cfe48a53a7f77230 Mon Sep 17 00:00:00 2001 From: jmf Date: Sat, 21 May 2016 01:05:20 +0200 Subject: [PATCH 03/12] [IMPL] Added mail.followers --- beesdoo_inventory/models/stock.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/beesdoo_inventory/models/stock.py b/beesdoo_inventory/models/stock.py index 562f6c9..efcbc72 100644 --- a/beesdoo_inventory/models/stock.py +++ b/beesdoo_inventory/models/stock.py @@ -6,3 +6,24 @@ class StockPicking(models.Model): max_shipping_date = fields.Datetime("End Shipping Date") responsible = fields.Many2one("res.partner", string="Responsible Person") + + def _add_follower(self): + self.env['mail.followers'].create({'partner_id': self.responsible.id, + 'res_id': self.id, + 'res_model': "stock.picking",}) + + @api.multi + def write(self, values): + res = super(StockPicking, self).write(values) + print "WRITE" + print values.get('responsible') + if values.get('responsible'): + for picking in self: + picking._add_follower() + return res + + @api.model + def create(self, values): + picking = super(StockPicking, self).create(values) + picking._add_follower() + return picking \ No newline at end of file From d1756a1fe6f9a0c94022447550a57105362b8575 Mon Sep 17 00:00:00 2001 From: jmf Date: Sat, 21 May 2016 01:32:45 +0200 Subject: [PATCH 04/12] [IMPL] Added 'responsible person' to stock picking tree view --- beesdoo_inventory/views/stock.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/beesdoo_inventory/views/stock.xml b/beesdoo_inventory/views/stock.xml index bdd0877..85fe537 100644 --- a/beesdoo_inventory/views/stock.xml +++ b/beesdoo_inventory/views/stock.xml @@ -1,6 +1,17 @@ + + beesdoo.stock.tree.view + stock.picking + + + + + + + + beesdoo.stock.form.view stock.picking From 018ee9044a64a1a333a55735247e7d536327829d Mon Sep 17 00:00:00 2001 From: EliseDup Date: Wed, 19 Oct 2016 09:48:00 +0200 Subject: [PATCH 05/12] Fix S0024 : add responsible as follower --- beesdoo_inventory/models/stock.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/beesdoo_inventory/models/stock.py b/beesdoo_inventory/models/stock.py index efcbc72..4d76c9a 100644 --- a/beesdoo_inventory/models/stock.py +++ b/beesdoo_inventory/models/stock.py @@ -5,21 +5,20 @@ class StockPicking(models.Model): _inherit = 'stock.picking' max_shipping_date = fields.Datetime("End Shipping Date") - responsible = fields.Many2one("res.partner", string="Responsible Person") + responsible = fields.Many2one('res.partner', string="Responsible") def _add_follower(self): - self.env['mail.followers'].create({'partner_id': self.responsible.id, - 'res_id': self.id, - 'res_model': "stock.picking",}) + if(self.responsible): + types = self.env['mail.message.subtype'].search(['|',('res_model','=','stock.picking'),('name','=','Discussions')]) + self.env['mail.followers'].create({'res_model' : 'stock.picking', + 'res_id' : self.id, + 'partner_id' : self.responsible.id, + 'subtype_ids': [(6, 0, types.ids)]}) @api.multi def write(self, values): res = super(StockPicking, self).write(values) - print "WRITE" - print values.get('responsible') - if values.get('responsible'): - for picking in self: - picking._add_follower() + self._add_follower() return res @api.model From af42bd8f539baa06b332a578e06f0838ce9bfbdd Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Tue, 25 Oct 2016 21:00:03 +0200 Subject: [PATCH 06/12] [FIX] task 0039 : Access right for user --- beesdoo_pos/models/beesdoo_pos.py | 1 + beesdoo_pos/security/ir.model.access.csv | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/beesdoo_pos/models/beesdoo_pos.py b/beesdoo_pos/models/beesdoo_pos.py index 43271bb..f9b8145 100644 --- a/beesdoo_pos/models/beesdoo_pos.py +++ b/beesdoo_pos/models/beesdoo_pos.py @@ -54,6 +54,7 @@ class BeescoopPosPartner(models.Model): @api.multi def get_balance_and_eater(self): self.ensure_one() + self = self.sudo() account_id = self.property_account_receivable_id.id move_lines = self.env['account.move.line'].search([('account_id', '=', account_id), ('partner_id', '=', self.id)]) credit = sum([m.credit for m in move_lines]) diff --git a/beesdoo_pos/security/ir.model.access.csv b/beesdoo_pos/security/ir.model.access.csv index eb8f2fd..9d85762 100644 --- a/beesdoo_pos/security/ir.model.access.csv +++ b/beesdoo_pos/security/ir.model.access.csv @@ -2,4 +2,4 @@ "bill_value_read_all","Read All","beesdoo_pos.model_bill_value","","True","False","False","False" "bill_value_accountant_all","All Comptable","beesdoo_pos.model_bill_value","account.group_account_user","True","True","True","True" "bill_value_pos_manager_all","All POS manager","beesdoo_pos.model_bill_value","point_of_sale.group_pos_manager","True","True","True","True" -"account_bank_statement_cashbox POS responsible Export","account.bank.statement.cashbox POS responsible Export","account.model_account_bank_statement_cashbox","point_of_sale.group_pos_manager","True","True","True","False" +"account_bank_statement_cashbox POS user","account.bank.statement.cashbox POS User","account.model_account_bank_statement_cashbox","point_of_sale.group_pos_user","True","True","True","False" From 21a339dda5b980b236c0a37074814a9539f0427a Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Sun, 9 Oct 2016 16:03:03 +0200 Subject: [PATCH 07/12] [FIX] improve error handling for coda import --- beesdoo_coda/wizard/import_coda.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beesdoo_coda/wizard/import_coda.py b/beesdoo_coda/wizard/import_coda.py index 3f378c4..7782794 100644 --- a/beesdoo_coda/wizard/import_coda.py +++ b/beesdoo_coda/wizard/import_coda.py @@ -5,7 +5,7 @@ Created on 16 mai 2016 @author: Thibault Francois (thibault@françois.be) ''' -from coda.parser import Parser +from coda.parser import Parser, CodaParserException from openerp import models, _ class CodaBankStatementImport(models.TransientModel): @@ -60,7 +60,7 @@ class CodaBankStatementImport(models.TransientModel): parser = Parser() try: statements = parser.parse(data_file) - except ValueError: + except CodaParserException: return super(CodaBankStatementImport, self)._parse_file(data_file) currency_code = False account_number = False From d84fad3d0d011e585b0216287940f81805d230b9 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Sun, 9 Oct 2016 16:04:16 +0200 Subject: [PATCH 08/12] [ADD] crelan import module --- beesdoo_crelan_csv/__init__.py | 2 + beesdoo_crelan_csv/__openerp__.py | 22 ++++ beesdoo_crelan_csv/wizard/__init__.py | 6 + .../wizard/import_crelan_csv.py | 120 ++++++++++++++++++ 4 files changed, 150 insertions(+) create mode 100644 beesdoo_crelan_csv/__init__.py create mode 100644 beesdoo_crelan_csv/__openerp__.py create mode 100644 beesdoo_crelan_csv/wizard/__init__.py create mode 100644 beesdoo_crelan_csv/wizard/import_crelan_csv.py diff --git a/beesdoo_crelan_csv/__init__.py b/beesdoo_crelan_csv/__init__.py new file mode 100644 index 0000000..56c29d9 --- /dev/null +++ b/beesdoo_crelan_csv/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import wizard diff --git a/beesdoo_crelan_csv/__openerp__.py b/beesdoo_crelan_csv/__openerp__.py new file mode 100644 index 0000000..3a252a3 --- /dev/null +++ b/beesdoo_crelan_csv/__openerp__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +{ + 'name': "Beescoop Coda Import module", + + 'summary': """ + Import Crelan CSV Wizard + """, + + 'description': """ + """, + + 'author': "Beescoop - Cellule IT", + 'website': "https://github.com/beescoop/Obeesdoo", + + 'category': 'Accounting & Finance', + 'version': '0.1', + + 'depends': ['account_bank_statement_import'], + + 'data': [ + ], +} diff --git a/beesdoo_crelan_csv/wizard/__init__.py b/beesdoo_crelan_csv/wizard/__init__.py new file mode 100644 index 0000000..bd91c43 --- /dev/null +++ b/beesdoo_crelan_csv/wizard/__init__.py @@ -0,0 +1,6 @@ +''' +Created on 09 octobre 2016 + +@author: Thibault Francois +''' +import import_crelan_csv \ No newline at end of file diff --git a/beesdoo_crelan_csv/wizard/import_crelan_csv.py b/beesdoo_crelan_csv/wizard/import_crelan_csv.py new file mode 100644 index 0000000..e89bfca --- /dev/null +++ b/beesdoo_crelan_csv/wizard/import_crelan_csv.py @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- +''' +Created on 09 Octobre 2016 + +@author: Thibault Francois (thibault@françois.be) +''' + +from StringIO import StringIO +import csv +import datetime +from openerp import models, _ + +ACCOUNT = "Compte donneur d'ordre" +CURRENCY = "Devise" +DATE = "Date" +AMOUNT = "Montant" +COUNTERPART_NUMBER = "Compte contrepartie" +COUNTERPART_NAME = "Contrepartie" +COMMUNICATION = "Communication" +TRANSACTION_TYPE = "Type d'op\xc3\xa9ration" + +class CodaBankStatementImport(models.TransientModel): + _inherit = 'account.bank.statement.import' + + _date_format = "%d/%m/%Y" + + _decimal_sep = "." + _csv_delimiter = ";" + _csv_quote = '"' + + _header = ['Date', 'Montant', 'Devise', 'Contrepartie', 'Compte contrepartie', "Type d'op\xc3\xa9ration", 'Communication', "Compte donneur d'ordre"] + + + def _generate_note(self, move): + notes = [] + notes.append("%s: %s" % (_('Counter Party Name'), move[COUNTERPART_NAME])) + notes.append("%s: %s" % (_('Counter Party Account'), move[COUNTERPART_NUMBER])) + notes.append("%s: %s" % (_('Communication'), move[COMMUNICATION])) + return '\n'.join(notes) + + def _get_move_value(self, move, sequence): + move_data = { + 'name': move[TRANSACTION_TYPE] + ": " + move[COMMUNICATION], + 'note': self._generate_note(move), + 'date': self._to_iso_date(move[DATE]), + 'amount': float(move[AMOUNT]), + 'account_number': move[COUNTERPART_NUMBER], #ok + 'partner_name': move[COUNTERPART_NAME], #ok + 'ref': move[DATE] + '-' + move[AMOUNT] + '-' + move[COUNTERPART_NUMBER] + '-' + move[COUNTERPART_NAME], + 'sequence': sequence, #ok + 'unique_import_id' : move[DATE] + '-' + move[AMOUNT] + '-' + move[COUNTERPART_NUMBER] + '-' + move[COUNTERPART_NAME] + } + return move_data + + def _get_statement_data(self, balance_start, balance_end, begin_date, end_date): + statement_data = { + 'name' : _("Bank Statement from %s to %s") % (begin_date, end_date), + 'date' : self._to_iso_date(end_date), + 'balance_start': balance_start, #ok + 'balance_end_real' : balance_end, #ok + 'transactions' : [] + } + return statement_data + + def _get_acc_number(self, acc_number): + #Check if we match the exact acc_number or the end of an acc number + journal = self.env['account.journal'].search([('bank_acc_number', '=like', '%' + acc_number)]) + if not journal or len(journal) > 1: #if not found or ambiguious + return acc_number + + return journal.bank_acc_number + + def _get_acc_balance(self, acc_number): + if not self.init_balance == None: + return self.init_balance + print "compute balance" + + journal = self.env['account.journal'].search([('bank_acc_number', '=like', '%' + acc_number)]) + if not journal or len(journal) > 1: #if not found or ambiguious + self.init_balance = 0.0 + else: + self.init_balance = float(journal.get_journal_dashboard_datas()['last_balance'][:-1].strip().replace(',', '')) + + return self.init_balance + + def _to_iso_date(self, orig_date): + date_obj = datetime.datetime.strptime(orig_date, self._date_format) + return date_obj.strftime('%Y-%m-%d') + + def _parse_file(self, data_file): + + try: + csv_file = StringIO(data_file) + data = csv.DictReader(csv_file, delimiter=self._csv_delimiter, quotechar=self._csv_quote) + if not data.fieldnames == self._header: + raise ValueError() + except ValueError: + return super(CodaBankStatementImport, self)._parse_file(data_file) + + currency_code = False + account_number = False + self.init_balance = None + begin_date = False + end_date = False + + transactions = [] + i = 1 + sum_transaction = 0 + for statement in data: + begin_date = begin_date or statement[DATE] + end_date = statement[DATE] + account_number = statement[ACCOUNT] + balance = self._get_acc_balance(account_number) + currency_code = statement[CURRENCY] + transactions.append(self._get_move_value(statement, i)) + sum_transaction += float(statement[AMOUNT]) + i += 1 + stmt = self._get_statement_data(balance, balance+ sum_transaction, begin_date, end_date) + stmt['transactions'] = transactions + return currency_code, self._get_acc_number(account_number), [stmt] From 4bbb2e063555c4b7a09252a203bfbaf3457ba55e Mon Sep 17 00:00:00 2001 From: EliseDup Date: Thu, 13 Oct 2016 08:34:00 +0200 Subject: [PATCH 09/12] Fix task 025, command@bees follower of purchase order --- beesdoo_purchase/models/purchase.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/beesdoo_purchase/models/purchase.py b/beesdoo_purchase/models/purchase.py index 5060dae..bf08392 100644 --- a/beesdoo_purchase/models/purchase.py +++ b/beesdoo_purchase/models/purchase.py @@ -8,7 +8,10 @@ class PurchaseOrder(models.Model): def create(self, vals): purchase_order = super(PurchaseOrder, self).create(vals) command_contact = self.env.ref('beesdoo_base.commande_beescoop', raise_if_not_found=False) - # We do not need to update sale_order.mail_followers_ids, the link is automatic ?! + types = self.env['mail.message.subtype'].search([('res_model','=','purchase.order')]) + if command_contact: - self.env['mail.followers'].create({'res_model' : 'purchase.order', 'res_id' : purchase_order.id, 'partner_id' : command_contact.id}) + self.message_subscribe(partner_ids=command_contact, subtype_ids=types) + # self.env['mail.followers'].create({'res_model' : 'purchase.order', 'res_id' : purchase_order.id, 'partner_id' : command_contact.id}) + return purchase_order \ No newline at end of file From 72372cd12c055a378359f69f271c60dfe1d6dac4 Mon Sep 17 00:00:00 2001 From: EliseDup Date: Mon, 17 Oct 2016 17:02:47 +0200 Subject: [PATCH 10/12] S0025 : fix. Add subtypes discussion and those linked to purchase_order --- beesdoo_purchase/models/purchase.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/beesdoo_purchase/models/purchase.py b/beesdoo_purchase/models/purchase.py index bf08392..9c907f8 100644 --- a/beesdoo_purchase/models/purchase.py +++ b/beesdoo_purchase/models/purchase.py @@ -8,10 +8,11 @@ class PurchaseOrder(models.Model): def create(self, vals): purchase_order = super(PurchaseOrder, self).create(vals) command_contact = self.env.ref('beesdoo_base.commande_beescoop', raise_if_not_found=False) - types = self.env['mail.message.subtype'].search([('res_model','=','purchase.order')]) + types = self.env['mail.message.subtype'].search(['|',('res_model','=','purchase.order'),('name','=','Discussions')]) if command_contact: - self.message_subscribe(partner_ids=command_contact, subtype_ids=types) - # self.env['mail.followers'].create({'res_model' : 'purchase.order', 'res_id' : purchase_order.id, 'partner_id' : command_contact.id}) - + self.env['mail.followers'].create({'res_model' : 'purchase.order', + 'res_id' : purchase_order.id, + 'partner_id' : command_contact.id, + 'subtype_ids': [(6, 0, types.ids)]}) return purchase_order \ No newline at end of file From 8ae7946d7a1b6d5a226b303d1b52e3105033e378 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Wed, 26 Oct 2016 10:26:14 +0200 Subject: [PATCH 11/12] [CLEAN] remove trailing space --- beesdoo_purchase/models/purchase.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/beesdoo_purchase/models/purchase.py b/beesdoo_purchase/models/purchase.py index 9c907f8..1a64f56 100644 --- a/beesdoo_purchase/models/purchase.py +++ b/beesdoo_purchase/models/purchase.py @@ -9,10 +9,10 @@ class PurchaseOrder(models.Model): purchase_order = super(PurchaseOrder, self).create(vals) command_contact = self.env.ref('beesdoo_base.commande_beescoop', raise_if_not_found=False) types = self.env['mail.message.subtype'].search(['|',('res_model','=','purchase.order'),('name','=','Discussions')]) - + if command_contact: - self.env['mail.followers'].create({'res_model' : 'purchase.order', - 'res_id' : purchase_order.id, + self.env['mail.followers'].create({'res_model' : 'purchase.order', + 'res_id' : purchase_order.id, 'partner_id' : command_contact.id, 'subtype_ids': [(6, 0, types.ids)]}) - return purchase_order \ No newline at end of file + return purchase_order From 4c88c2d4ec303e8787072a78994d5a79f90d028b Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Tue, 1 Nov 2016 16:24:28 +0100 Subject: [PATCH 12/12] [ADD] first dashboard --- beesdoo_report/__init__.py | 2 ++ beesdoo_report/__openerp__.py | 32 +++++++++++++++++ beesdoo_report/report/__init__.py | 1 + beesdoo_report/report/report_visit.py | 50 ++++++++++++++++++++++++++ beesdoo_report/report/views/board.xml | 41 +++++++++++++++++++++ beesdoo_report/report/views/visits.xml | 45 +++++++++++++++++++++++ 6 files changed, 171 insertions(+) create mode 100644 beesdoo_report/__init__.py create mode 100644 beesdoo_report/__openerp__.py create mode 100644 beesdoo_report/report/__init__.py create mode 100644 beesdoo_report/report/report_visit.py create mode 100644 beesdoo_report/report/views/board.xml create mode 100644 beesdoo_report/report/views/visits.xml diff --git a/beesdoo_report/__init__.py b/beesdoo_report/__init__.py new file mode 100644 index 0000000..9e06818 --- /dev/null +++ b/beesdoo_report/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import report \ No newline at end of file diff --git a/beesdoo_report/__openerp__.py b/beesdoo_report/__openerp__.py new file mode 100644 index 0000000..a65c423 --- /dev/null +++ b/beesdoo_report/__openerp__.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +{ + 'name': "Beescoop Report Module", + + 'summary': """ + Module that generate report for Beescoop + """, + + 'description': """ + Beescoop Report + """, + + 'author': "Beescoop - Cellule IT", + 'website': "https://github.com/beescoop/Obeesdoo", + + # Categories can be used to filter modules in modules listing + # Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml + # for the full list + 'category': 'Point Of Sale', + 'version': '0.1', + + 'depends': ['beesdoo_base', 'beesdoo_pos', 'board'], + + 'data': [ + #YOU PUT YOUR XML HERE + 'report/views/visits.xml', #Should remain the first one + + + 'report/views/board.xml', #Should be after the sql view's views + ], +} + diff --git a/beesdoo_report/report/__init__.py b/beesdoo_report/report/__init__.py new file mode 100644 index 0000000..a232dcd --- /dev/null +++ b/beesdoo_report/report/__init__.py @@ -0,0 +1 @@ +import report_visit diff --git a/beesdoo_report/report/report_visit.py b/beesdoo_report/report/report_visit.py new file mode 100644 index 0000000..60a81c0 --- /dev/null +++ b/beesdoo_report/report/report_visit.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +from openerp import tools +from openerp import models, fields, api + +#---------------- +class ReportVisit(models.Model): + _name = "beesdoo.report.visits" + _description = "Labo Market Visit" + _auto = False + _order = 'week desc' + + week = fields.Date("Week") + type = fields.Char() + visitors = fields.Integer("Visitors") + visits = fields.Integer("Visits") + #gross_sale = fields.Float("Gross Sales") + + def init(self, cr): + # self._table = account_invoice_report + tools.drop_view_if_exists(cr, self._table) + cr.execute("""CREATE or REPLACE VIEW beesdoo_report_visits as ( + select + row_number() over() as id, + week, + type, + visits + from( + select + date_trunc('WEEK', date_order )::date as week, + count (distinct partner_id) + sum (case when partner_id is null then 1 else 0 end ) - 1 as visits, + 'visites_uniques' as type + from + pos_order + group by + date_trunc('WEEK', date_order) + union + select + date_trunc('WEEK', date_order )::date as week, + count (distinct id) as visits, + 'visites' as type + from + pos_order + group by + date_trunc('WEEK', date_order) + ) t + + order by + week, type desc + + )""") \ No newline at end of file diff --git a/beesdoo_report/report/views/board.xml b/beesdoo_report/report/views/board.xml new file mode 100644 index 0000000..5d01f35 --- /dev/null +++ b/beesdoo_report/report/views/board.xml @@ -0,0 +1,41 @@ + + + + Report on visits + beesdoo.report.visits + graph + + + + + Beesdoo Dashboard + board.board + form + +
+ + + + + + + +
+
+
+ + + + Beescoop Dashboard + board.board + form + form + menu + + + + +
\ No newline at end of file diff --git a/beesdoo_report/report/views/visits.xml b/beesdoo_report/report/views/visits.xml new file mode 100644 index 0000000..27421be --- /dev/null +++ b/beesdoo_report/report/views/visits.xml @@ -0,0 +1,45 @@ + + + + + beesdoo.report.visits.pivot + beesdoo.report.visits + + + + + + + + + + + beesdoo.report.visits.graph + beesdoo.report.visits + + + + + + + + + + + + Report on visits + beesdoo.report.visits + pivot,graph + + + + + + + \ No newline at end of file