Browse Source

Merge branch '9.0' into 9.0-s0011-elise

pull/14/head
EliseDup 8 years ago
parent
commit
898391d640
  1. 4
      beesdoo_coda/wizard/import_coda.py
  2. 2
      beesdoo_crelan_csv/__init__.py
  3. 22
      beesdoo_crelan_csv/__openerp__.py
  4. 6
      beesdoo_crelan_csv/wizard/__init__.py
  5. 120
      beesdoo_crelan_csv/wizard/import_crelan_csv.py
  6. 2
      beesdoo_inventory/__init__.py
  7. 31
      beesdoo_inventory/__openerp__.py
  8. 2
      beesdoo_inventory/models/__init__.py
  9. 28
      beesdoo_inventory/models/stock.py
  10. 29
      beesdoo_inventory/views/stock.xml
  11. 1
      beesdoo_pos/models/beesdoo_pos.py
  12. 2
      beesdoo_pos/security/ir.model.access.csv
  13. 10
      beesdoo_purchase/models/purchase.py
  14. 2
      beesdoo_report/__init__.py
  15. 32
      beesdoo_report/__openerp__.py
  16. 1
      beesdoo_report/report/__init__.py
  17. 50
      beesdoo_report/report/report_visit.py
  18. 41
      beesdoo_report/report/views/board.xml
  19. 45
      beesdoo_report/report/views/visits.xml

4
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

2
beesdoo_crelan_csv/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
import wizard

22
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': [
],
}

6
beesdoo_crelan_csv/wizard/__init__.py

@ -0,0 +1,6 @@
'''
Created on 09 octobre 2016
@author: Thibault Francois
'''
import import_crelan_csv

120
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]

2
beesdoo_inventory/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
import models

31
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': [],
}

2
beesdoo_inventory/models/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
import stock

28
beesdoo_inventory/models/stock.py

@ -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

29
beesdoo_inventory/views/stock.xml

@ -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>

1
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])

2
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"

10
beesdoo_purchase/models/purchase.py

@ -8,7 +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)
# 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'),('name','=','Discussions')])
if command_contact:
self.env['mail.followers'].create({'res_model' : 'purchase.order', 'res_id' : purchase_order.id, 'partner_id' : command_contact.id})
return purchase_order
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

2
beesdoo_report/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
import report

32
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
],
}

1
beesdoo_report/report/__init__.py

@ -0,0 +1 @@
import report_visit

50
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
)""")

41
beesdoo_report/report/views/board.xml

@ -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>

45
beesdoo_report/report/views/visits.xml

@ -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>
Loading…
Cancel
Save