EliseDup
8 years ago
19 changed files with 424 additions and 5 deletions
-
4beesdoo_coda/wizard/import_coda.py
-
2beesdoo_crelan_csv/__init__.py
-
22beesdoo_crelan_csv/__openerp__.py
-
6beesdoo_crelan_csv/wizard/__init__.py
-
120beesdoo_crelan_csv/wizard/import_crelan_csv.py
-
2beesdoo_inventory/__init__.py
-
31beesdoo_inventory/__openerp__.py
-
2beesdoo_inventory/models/__init__.py
-
28beesdoo_inventory/models/stock.py
-
29beesdoo_inventory/views/stock.xml
-
1beesdoo_pos/models/beesdoo_pos.py
-
1beesdoo_pos/security/ir.model.access.csv
-
10beesdoo_purchase/models/purchase.py
-
2beesdoo_report/__init__.py
-
32beesdoo_report/__openerp__.py
-
1beesdoo_report/report/__init__.py
-
50beesdoo_report/report/report_visit.py
-
41beesdoo_report/report/views/board.xml
-
45beesdoo_report/report/views/visits.xml
@ -0,0 +1,2 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
import wizard |
@ -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': [ |
||||
|
], |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
''' |
||||
|
Created on 09 octobre 2016 |
||||
|
|
||||
|
@author: Thibault Francois |
||||
|
''' |
||||
|
import import_crelan_csv |
@ -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] |
@ -0,0 +1,2 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
import models |
@ -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': [], |
||||
|
} |
@ -0,0 +1,2 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
import stock |
@ -0,0 +1,28 @@ |
|||||
|
# -*- 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") |
||||
|
|
||||
|
def _add_follower(self): |
||||
|
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) |
||||
|
self._add_follower() |
||||
|
return res |
||||
|
|
||||
|
@api.model |
||||
|
def create(self, values): |
||||
|
picking = super(StockPicking, self).create(values) |
||||
|
picking._add_follower() |
||||
|
return picking |
@ -0,0 +1,29 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
|
||||
|
<record model="ir.ui.view" id="beesdoo_stock_tree_view"> |
||||
|
<field name="name">beesdoo.stock.tree.view</field> |
||||
|
<field name="model">stock.picking</field> |
||||
|
<field name="inherit_id" ref="stock.vpicktree" /> |
||||
|
<field name="arch" type="xml"> |
||||
|
<field name="partner_id" position="after"> |
||||
|
<field name="responsible" /> |
||||
|
</field> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record model="ir.ui.view" id="beesdoo_stock_form_view"> |
||||
|
<field name="name">beesdoo.stock.form.view</field> |
||||
|
<field name="model">stock.picking</field> |
||||
|
<field name="inherit_id" ref="stock.view_picking_form" /> |
||||
|
<field name="arch" type="xml"> |
||||
|
<field name="min_date" position="after"> |
||||
|
<field name="max_shipping_date" placeholder="Max shipping date" /> |
||||
|
</field> |
||||
|
<field name="backorder_id" position="after"> |
||||
|
<field name="responsible" /> |
||||
|
</field> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
</odoo> |
@ -0,0 +1,2 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
import report |
@ -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 |
||||
|
], |
||||
|
} |
||||
|
|
@ -0,0 +1 @@ |
|||||
|
import report_visit |
@ -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 |
||||
|
|
||||
|
)""") |
@ -0,0 +1,41 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<record model="ir.actions.act_window" id="beesdoo_report_visits_action_board"> |
||||
|
<field name="name">Report on visits</field> |
||||
|
<field name="res_model">beesdoo.report.visits</field> |
||||
|
<field name="view_mode">graph</field> |
||||
|
</record> |
||||
|
|
||||
|
|
||||
|
<record model="ir.ui.view" id="board_pos_beesdoo_form"> |
||||
|
<field name="name">Beesdoo Dashboard</field> |
||||
|
<field name="model">board.board</field> |
||||
|
<field name="type">form</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Dashboard"> |
||||
|
<board style="1-1"> |
||||
|
<column> |
||||
|
<action string="Visits" |
||||
|
name="%(beesdoo_report_visits_action_board)d" /> |
||||
|
</column> |
||||
|
<column> |
||||
|
</column> |
||||
|
</board> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
|
||||
|
<record model="ir.actions.act_window" id="open_board_pos_beesdoo"> |
||||
|
<field name="name">Beescoop Dashboard</field> |
||||
|
<field name="res_model">board.board</field> |
||||
|
<field name="view_type">form</field> |
||||
|
<field name="view_mode">form</field> |
||||
|
<field name="usage">menu</field> |
||||
|
<field name="view_id" ref="board_pos_beesdoo_form" /> |
||||
|
</record> |
||||
|
|
||||
|
<menuitem name="General Dashboard" parent="base.menu_reporting_dashboard" |
||||
|
action="open_board_pos_beesdoo" sequence="1" |
||||
|
id="beesdoo_general_dashboard" /> |
||||
|
</odoo> |
@ -0,0 +1,45 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<!-- vue --> |
||||
|
<record model="ir.ui.view" id="beesdoo_report_visits_pivot"> |
||||
|
<field name="name">beesdoo.report.visits.pivot</field> |
||||
|
<field name="model">beesdoo.report.visits</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<pivot> |
||||
|
<field name="week" /> |
||||
|
<field name="type" type="column"/> |
||||
|
<field name="visits" type="measure"/> |
||||
|
</pivot> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record model="ir.ui.view" id="beesdoo_report_visits_graph"> |
||||
|
<field name="name">beesdoo.report.visits.graph</field> |
||||
|
<field name="model">beesdoo.report.visits</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<graph type="bar" stacked="False"> |
||||
|
<field name="week" /> |
||||
|
<field name="type" /> |
||||
|
<field name="visits" type="measure"/> |
||||
|
</graph> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<!-- Action --> |
||||
|
<record model="ir.actions.act_window" id="beesdoo_report_visits_action"> |
||||
|
<field name="name">Report on visits</field> |
||||
|
<field name="res_model">beesdoo.report.visits</field> |
||||
|
<field name="view_mode">pivot,graph</field> |
||||
|
</record> |
||||
|
<!-- ir.ui.menu --> |
||||
|
|
||||
|
<menuitem id="beesdoo_report" |
||||
|
parent="base.menu_reporting_config" |
||||
|
|
||||
|
name="Beesdoo report" /> |
||||
|
|
||||
|
<menuitem id="beesdoo_report_visit" |
||||
|
parent="beesdoo_report" |
||||
|
name="Visits report" |
||||
|
action="beesdoo_report_visits_action" /> |
||||
|
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue