Browse Source

[REF] blacken

pull/142/head
robin.keunen 4 years ago
parent
commit
ee1a5f85d0
  1. 1
      .dockerignore
  2. 3
      README.md
  3. 2
      beesdoo_account/readme/CONTRIBUTORS.rst
  4. 44
      beesdoo_base/__manifest__.py
  5. 1
      beesdoo_base/demo/eaters.xml
  6. 29
      beesdoo_base/models/membercard.py
  7. 88
      beesdoo_base/models/partner.py
  8. 2
      beesdoo_base/readme/CONTRIBUTORS.rst
  9. 4
      beesdoo_base/security/ir.model.access.csv
  10. 47
      beesdoo_base/wizard/member_card.py
  11. 18
      beesdoo_base/wizard/partner.py
  12. 30
      beesdoo_base/wizard/portal_wizard.py
  13. 23
      beesdoo_crelan_csv/__manifest__.py
  14. 2
      beesdoo_crelan_csv/models/account_journal.py
  15. 129
      beesdoo_crelan_csv/wizard/import_crelan_csv.py
  16. 47
      beesdoo_easy_my_coop/__manifest__.py
  17. 27
      beesdoo_easy_my_coop/controllers/main.py
  18. 8
      beesdoo_easy_my_coop/models/product.py
  19. 20
      beesdoo_easy_my_coop/models/res_company.py
  20. 40
      beesdoo_easy_my_coop/models/res_partner.py
  21. 13
      beesdoo_easy_my_coop/models/subscription_request.py
  22. 50
      beesdoo_easy_my_coop/tests/test_res_partner.py
  23. 13
      beesdoo_easy_my_coop/wizards/beesdoo_shift_subscribe.py
  24. 25
      beesdoo_inventory/__manifest__.py
  25. 43
      beesdoo_inventory/models/stock.py
  26. 2
      beesdoo_inventory/readme/CONTRIBUTORS.rst
  27. 2
      beesdoo_pos/__init__.py
  28. 32
      beesdoo_pos/__manifest__.py
  29. 2
      beesdoo_pos/models/__init__.py
  30. 4
      beesdoo_pos/models/beesdoo_pos.py
  31. 2
      beesdoo_pos/readme/CONTRIBUTORS.rst
  32. 2
      beesdoo_pos/static/src/css/beesdoo.css
  33. 2
      beesdoo_pos_reporting/models/res_partner.py
  34. 2
      beesdoo_pos_reporting/readme/CONTRIBUTORS.rst
  35. 38
      beesdoo_product/__manifest__.py
  36. 28
      beesdoo_product/data/product_sequence.xml
  37. 2
      beesdoo_product/models/__init__.py
  38. 281
      beesdoo_product/models/beesdoo_product.py
  39. 2
      beesdoo_product/readme/CONTRIBUTORS.rst
  40. 10
      beesdoo_product/security/ir.model.access.csv
  41. 24
      beesdoo_product/wizard/label_printing_utils.py
  42. 28
      beesdoo_product_usability/__manifest__.py
  43. 16
      beesdoo_product_usability/models/beesdoo_product.py
  44. 5
      beesdoo_purchase/__manifest__.py
  45. 38
      beesdoo_shift/__manifest__.py
  46. 1
      beesdoo_shift/models/__init__.py
  47. 295
      beesdoo_shift/models/cooperative_status.py
  48. 225
      beesdoo_shift/models/planning.py
  49. 127
      beesdoo_shift/models/res_partner.py
  50. 236
      beesdoo_shift/models/task.py
  51. 2
      beesdoo_shift/readme/CONTRIBUTORS.rst
  52. 21
      beesdoo_shift/wizard/assign_super_coop.py
  53. 72
      beesdoo_shift/wizard/batch_template.py
  54. 64
      beesdoo_shift/wizard/extension.py
  55. 41
      beesdoo_shift/wizard/holiday.py
  56. 36
      beesdoo_shift/wizard/instanciate_planning.py
  57. 193
      beesdoo_shift/wizard/subscribe.py
  58. 50
      beesdoo_shift/wizard/temporary_exemption.py
  59. 38
      beesdoo_shift_attendance/__manifest__.py
  60. 47
      beesdoo_shift_attendance/models/attendance_sheet.py
  61. 4
      beesdoo_shift_attendance/models/res_config_settings.py
  62. 22
      beesdoo_shift_attendance/tests/test_beesdoo_shift.py
  63. 8
      beesdoo_shift_attendance/wizard/generate_missing_attendance_sheets.py
  64. 7
      beesdoo_shift_attendance/wizard/validate_attendance_sheet.py
  65. 10
      beesdoo_stock/__manifest__.py
  66. 30
      beesdoo_stock/models/stock.py
  67. 2
      beesdoo_stock_coverage/models/product_template.py
  68. 1
      beesdoo_stock_coverage/readme/CONTRIBUTORS.rst
  69. 5
      beesdoo_stock_coverage/tests/test_stock_coverage.py
  70. 31
      beesdoo_website_eater/__manifest__.py
  71. 10
      beesdoo_website_eater/controllers/main.py
  72. 22
      beesdoo_website_posorder_amount/controllers/main.py
  73. 6
      beesdoo_website_shift/__manifest__.py
  74. 355
      beesdoo_website_shift/controllers/main.py
  75. 29
      beesdoo_website_shift/models/res_config.py
  76. 21
      beesdoo_website_shift/models/website.py
  77. 2
      beesdoo_website_shift/readme/CONTRIBUTORS.rst
  78. 29
      beesdoo_website_theme/__manifest__.py
  79. 2
      beesdoo_website_theme/readme/CONTRIBUTORS.rst
  80. 40
      beesdoo_worker_status/__manifest__.py
  81. 256
      beesdoo_worker_status/models/cooperative_status.py
  82. 44
      beesdoo_worker_status/models/task.py
  83. 2
      initial-data-load/01_readme.md
  84. 14
      install-odoo-docker.md
  85. 512
      install-odoo-linux-server.md
  86. 1
      install-odoo-linux.md
  87. 2
      macavrac_base/__init__.py
  88. 26
      macavrac_base/__manifest__.py
  89. 2
      macavrac_base/models/__init__.py
  90. 74
      macavrac_base/models/res_partner.py
  91. 2
      purchase_order_generator/models/product_template.py
  92. 2
      purchase_order_generator/models/purchase_order.py
  93. 5
      purchase_order_generator/models/purchase_order_generator.py
  94. 4
      purchase_order_generator/models/purchase_order_generator_line.py
  95. 2
      purchase_order_generator/tests/test_pog.py
  96. 4
      website_portal_restrict_modification/controllers/main.py

1
.dockerignore

@ -1,2 +1 @@
*

3
README.md

@ -59,7 +59,7 @@ $ gunzip <dump-file>.sql.gz
$ psql beescoop < <dump-file>.sql
```
##### 4) deactivate cron jobs and mails
##### 4) deactivate cron jobs and mails
```
$ psql -d beescoop -c "UPDATE ir_cron SET active='f' WHERE active='t';"
@ -131,4 +131,3 @@ $ python odoo.py -c $ODOO_HOME/odoo.conf -u all -d beescoop --stop-after-init
insert into member_card (active, barcode, partner_id, responsible_id, activation_date) select 't', barcode, id, 1, '2016-01-01' from res_partner where barcode is not null;
update res_partner set eater = 'worker_eater' where barcode is not null;
```

2
beesdoo_account/readme/CONTRIBUTORS.rst

@ -0,0 +1,2 @@
* Beescoop - Cellule IT
* Coop IT Easy SCRLfs

44
beesdoo_base/__manifest__.py

@ -6,34 +6,24 @@
# - Thibault François
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "Beescoop Base Module",
'summary': """
"name": "Beescoop Base Module",
"summary": """
Module that customize the base module and contains some python tools
""",
'description': """
""",
'author': "Beescoop - Cellule IT",
'website': "https://github.com/beescoop/Obeesdoo",
'category': 'Sales',
'version': '12.0.1.0.0',
'depends': ['point_of_sale', 'purchase', 'portal', 'partner_firstname'],
'data': [
'security/groups.xml',
'security/ir.model.access.csv',
'views/partner.xml',
'wizard/views/member_card.xml',
'wizard/views/partner.xml',
'report/beescard.xml',
"author": "Beescoop - Cellule IT, Coop IT Easy SCRLfs",
"website": "https://github.com/beescoop/Obeesdoo",
"category": "Sales",
"version": "12.0.1.0.0",
"depends": ["point_of_sale", "purchase", "portal", "partner_firstname"],
"data": [
"security/groups.xml",
"security/ir.model.access.csv",
"views/partner.xml",
"wizard/views/member_card.xml",
"wizard/views/partner.xml",
"report/beescard.xml",
],
'installable': True,
'demo': [
'demo/cooperators.xml',
'demo/eaters.xml',
]
"installable": True,
"demo": ["demo/cooperators.xml", "demo/eaters.xml",],
"license": "AGPL-3",
}

1
beesdoo_base/demo/eaters.xml

@ -40,4 +40,3 @@
<field name="customer" eval="True"/>
</record>
</odoo>

29
beesdoo_base/models/membercard.py

@ -1,24 +1,35 @@
from odoo import models, fields, api
import uuid
class MemberCard(models.Model):
from odoo import api, fields, models
class MemberCard(models.Model):
def _get_current_user(self):
return self.env.uid
def _compute_bar_code(self):
rule = self.env['barcode.rule'].search([('name', '=', 'Customer Barcodes')])[0]
rule = self.env["barcode.rule"].search(
[("name", "=", "Customer Barcodes")]
)[0]
size = 13 - len(rule.pattern)
ean = rule.pattern + str(uuid.uuid4().fields[-1])[:size]
return ean[0:12] + str(self.env['barcode.nomenclature'].ean_checksum(ean))
return ean[0:12] + str(
self.env["barcode.nomenclature"].ean_checksum(ean)
)
_name = 'member.card'
_order = 'create_date desc'
_name = "member.card"
_order = "create_date desc"
_description = "Member Card"
valid = fields.Boolean(default=True, string="Active")
barcode = fields.Char("Barcode", oldname='ean13', default=_compute_bar_code)
partner_id = fields.Many2one('res.partner') #, default=_get_current_client)
responsible_id = fields.Many2one('res.users', default=_get_current_user, string="Responsible")
barcode = fields.Char(
"Barcode", oldname="ean13", default=_compute_bar_code
)
partner_id = fields.Many2one(
"res.partner"
) # , default=_get_current_client)
responsible_id = fields.Many2one(
"res.users", default=_get_current_user, string="Responsible"
)
end_date = fields.Date(readonly=True, string="Expiration Date")
comment = fields.Char("Reason", required=True)

88
beesdoo_base/models/partner.py

@ -1,24 +1,42 @@
from odoo import models, fields, api, _
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class Partner(models.Model):
_inherit = 'res.partner'
_inherit = "res.partner"
eater = fields.Selection([('eater', 'Eater'), ('worker_eater', 'Worker and Eater')], string="Eater/Worker")
child_eater_ids = fields.One2many("res.partner", "parent_eater_id", domain=[('customer', '=', True),
('eater', '=', 'eater')])
parent_eater_id = fields.Many2one("res.partner", string="Parent Worker", readonly=True)
barcode = fields.Char(compute="_get_bar_code", string='Barcode', store=True)
parent_barcode = fields.Char(compute="_get_bar_code", string='Parent Barcode', store=True)
member_card_ids = fields.One2many('member.card', 'partner_id')
eater = fields.Selection(
[("eater", "Eater"), ("worker_eater", "Worker and Eater")],
string="Eater/Worker",
)
child_eater_ids = fields.One2many(
"res.partner",
"parent_eater_id",
domain=[("customer", "=", True), ("eater", "=", "eater")],
)
parent_eater_id = fields.Many2one(
"res.partner", string="Parent Worker", readonly=True
)
barcode = fields.Char(
compute="_get_bar_code", string="Barcode", store=True
)
parent_barcode = fields.Char(
compute="_get_bar_code", string="Parent Barcode", store=True
)
member_card_ids = fields.One2many("member.card", "partner_id")
member_card_to_be_printed = fields.Boolean('Print BEES card?')
last_printed = fields.Datetime('Last printed on')
member_card_to_be_printed = fields.Boolean("Print BEES card?")
last_printed = fields.Datetime("Last printed on")
@api.depends('parent_eater_id', 'parent_eater_id.barcode', 'eater', 'member_card_ids')
@api.depends(
"parent_eater_id",
"parent_eater_id.barcode",
"eater",
"member_card_ids",
)
def _get_bar_code(self):
for rec in self:
if rec.eater == 'eater':
if rec.eater == "eater":
rec.parent_barcode = rec.parent_eater_id.barcode
elif rec.member_card_ids:
for c in rec.member_card_ids:
@ -29,45 +47,49 @@ class Partner(models.Model):
def write(self, values):
for rec in self:
if (
values.get('parent_eater_id')
values.get("parent_eater_id")
and rec.parent_eater_id
and rec.parent_eater_id.id != values.get("parent_eater_id")
):
raise ValidationError(_('You try to assign a eater to a worker but this eater is already assign to %s please remove it before') % rec.parent_eater_id.name)
raise ValidationError(
_(
"You try to assign a eater to a worker but this eater is already assign to %s please remove it before"
)
% rec.parent_eater_id.name
)
# replace many2many command when writing on child_eater_ids to just remove the link
if 'child_eater_ids' in values:
for command in values['child_eater_ids']:
if "child_eater_ids" in values:
for command in values["child_eater_ids"]:
if command[0] == 2:
command[0] = 3
return super(Partner, self).write(values)
def _deactivate_active_cards(self):
self.ensure_one()
for card in self.member_card_ids.filtered('valid'):
for card in self.member_card_ids.filtered("valid"):
card.valid = False
card.end_date = fields.Date.today()
@api.multi
def _new_card(self, reason, user_id, barcode=False):
card_data = {
'partner_id' : self.id,
'responsible_id' : user_id,
'comment' : reason,
"partner_id": self.id,
"responsible_id": user_id,
"comment": reason,
}
if barcode:
card_data['barcode'] = barcode
self.env['member.card'].create(card_data)
card_data["barcode"] = barcode
self.env["member.card"].create(card_data)
@api.multi
def _new_eater(self, surname, name, email):
partner_data = {
'lastname' : name,
'firstname' : surname,
'is_customer' : True,
'eater' : 'eater',
'parent_eater_id' : self.id,
'email' : email,
'country_id' : self.country_id.id
}
return self.env['res.partner'].create(partner_data)
"lastname": name,
"firstname": surname,
"is_customer": True,
"eater": "eater",
"parent_eater_id": self.id,
"email": email,
"country_id": self.country_id.id,
}
return self.env["res.partner"].create(partner_data)

2
beesdoo_base/readme/CONTRIBUTORS.rst

@ -0,0 +1,2 @@
* Beescoop - Cellule IT
* Coop IT Easy SCRLfs

4
beesdoo_base/security/ir.model.access.csv

@ -1,2 +1,2 @@
"id","name","model_id/id","group_id/id","perm_read","perm_write","perm_create","perm_unlink"
"member_card_read_all","member card read all","beesdoo_base.model_member_card","","True","False","False","False"
"id","name","model_id/id","group_id/id","perm_read","perm_write","perm_create","perm_unlink"
"member_card_read_all","member card read all","beesdoo_base.model_member_card","","True","False","False","False"

47
beesdoo_base/wizard/member_card.py

@ -1,4 +1,5 @@
from odoo import models, fields, api
from odoo import api, fields, models
class NewMemberCardWizard(models.TransientModel):
"""
@ -6,49 +7,61 @@ class NewMemberCardWizard(models.TransientModel):
The user can only define the raison why a new card is
needed and the eater/worker that is concerned.
"""
_name = 'membercard.new.wizard'
_name = "membercard.new.wizard"
_description = "Member Card"
def _get_default_partner(self):
return self.env.context['active_id']
return self.env.context["active_id"]
new_comment = fields.Char('Reason', required=True)
partner_id = fields.Many2one('res.partner', default=_get_default_partner)
force_barcode = fields.Char('Force Barcode', groups="beesdoo_base.group_force_barcode")
new_comment = fields.Char("Reason", required=True)
partner_id = fields.Many2one("res.partner", default=_get_default_partner)
force_barcode = fields.Char(
"Force Barcode", groups="beesdoo_base.group_force_barcode"
)
@api.one
def create_new_card(self):
client = self.partner_id.sudo()
client._deactivate_active_cards()
client._new_card(self.new_comment, self.env.uid, barcode=self.force_barcode)
client._new_card(
self.new_comment, self.env.uid, barcode=self.force_barcode
)
client.member_card_to_be_printed = True
class RequestMemberCardPrintingWizard(models.TransientModel):
_name = 'membercard.requestprinting.wizard'
_name = "membercard.requestprinting.wizard"
_description = "Member Card - Request Print Wizard"
def _get_selected_partners(self):
return self.env.context['active_ids']
partner_ids = fields.Many2many('res.partner', default=_get_selected_partners)
return self.env.context["active_ids"]
partner_ids = fields.Many2many(
"res.partner", default=_get_selected_partners
)
@api.one
def request_printing(self):
self.partner_ids.write({'member_card_to_be_printed' : True})
self.partner_ids.write({"member_card_to_be_printed": True})
class SetAsPrintedWizard(models.TransientModel):
_name = 'membercard.set_as_printed.wizard'
_name = "membercard.set_as_printed.wizard"
_description = "Member card - Set as printed wizard"
def _get_selected_partners(self):
return self.env.context['active_ids']
return self.env.context["active_ids"]
partner_ids = fields.Many2many('res.partner', default=_get_selected_partners)
partner_ids = fields.Many2many(
"res.partner", default=_get_selected_partners
)
@api.one
def set_as_printed(self):
self.partner_ids.write({'member_card_to_be_printed' : False,
'last_printed' : fields.Datetime.now()})
self.partner_ids.write(
{
"member_card_to_be_printed": False,
"last_printed": fields.Datetime.now(),
}
)

18
beesdoo_base/wizard/partner.py

@ -1,20 +1,22 @@
from odoo import models, fields, api
from odoo import api, fields, models
class NewEaterWizard(models.TransientModel):
"""
A transient model for the creation of a eater related to a worker.
"""
_name = 'eater.new.wizard'
_description = 'eater.new.wizard'
_name = "eater.new.wizard"
_description = "eater.new.wizard"
def _get_default_partner(self):
return self.env.context['active_id']
return self.env.context["active_id"]
first_name = fields.Char('First Name', required=True)
last_name = fields.Char('Last Name', required=True)
email = fields.Char('Email')
first_name = fields.Char("First Name", required=True)
last_name = fields.Char("Last Name", required=True)
email = fields.Char("Email")
partner_id = fields.Many2one('res.partner', default=_get_default_partner)
partner_id = fields.Many2one("res.partner", default=_get_default_partner)
@api.one
def create_new_eater(self):

30
beesdoo_base/wizard/portal_wizard.py

@ -1,25 +1,29 @@
from odoo import models, fields, api
from odoo import SUPERUSER_ID
from odoo import SUPERUSER_ID, api, fields, models
class BeesdooWizard(models.TransientModel):
_inherit = 'portal.wizard'
_inherit = "portal.wizard"
@api.onchange('portal_id')
@api.onchange("portal_id")
def onchange_portal(self):
# for each partner, determine corresponding portal.wizard.user records
res_partner = self.env['res.partner']
partner_ids = self._context.get('active_ids', [])
res_partner = self.env["res.partner"]
partner_ids = self._context.get("active_ids", [])
contact_ids = set()
for partner in res_partner.browse(partner_ids):
for contact in (partner.child_ids | partner):
for contact in partner.child_ids | partner:
# make sure that each contact appears at most once in the list
if contact.id not in contact_ids:
contact_ids.add(contact.id)
in_portal = self.portal_id in contact.user_ids.mapped('groups_id')
self.user_ids |= self.env['portal.wizard.user'].new({
'partner_id': contact.id,
'email': contact.email,
'in_portal': in_portal,
})
in_portal = self.portal_id in contact.user_ids.mapped(
"groups_id"
)
self.user_ids |= self.env["portal.wizard.user"].new(
{
"partner_id": contact.id,
"email": contact.email,
"in_portal": in_portal,
}
)

23
beesdoo_crelan_csv/__manifest__.py

@ -3,21 +3,16 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "Beescoop Crelan Import module",
'summary': """
"name": "Beescoop Crelan Import module",
"summary": """
Import Crelan CSV Wizard
""",
'description': """
"description": """
""",
'author': "Beescoop - Cellule IT",
'website': "https://github.com/beescoop/Obeesdoo",
'category': 'Accounting & Finance',
'version': '12.0.1.0.0',
'depends': ['account_bank_statement_import'],
'installable': True,
"author": "Beescoop - Cellule IT",
"website": "https://github.com/beescoop/Obeesdoo",
"category": "Accounting & Finance",
"version": "12.0.1.0.0",
"depends": ["account_bank_statement_import"],
"installable": True,
}

2
beesdoo_crelan_csv/models/account_journal.py

@ -6,5 +6,5 @@ class AccountJournal(models.Model):
def _get_bank_statements_available_import_formats(self):
formats_list = super()._get_bank_statements_available_import_formats()
formats_list.append('Crelan')
formats_list.append("Crelan")
return formats_list

129
beesdoo_crelan_csv/wizard/import_crelan_csv.py

@ -1,8 +1,9 @@
from io import StringIO
import csv
import datetime
import hashlib
from odoo import models, _
from io import StringIO
from odoo import _, models
ACCOUNT = "Compte donneur d'ordre"
CURRENCY = "Devise"
@ -13,83 +14,125 @@ COUNTERPART_NAME = "Contrepartie"
COMMUNICATION = "Communication"
TRANSACTION_TYPE = "Type d'opération"
class CodaBankStatementImport(models.TransientModel):
_inherit = 'account.bank.statement.import'
_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ération",
'Communication', "Compte donneur d'ordre"]
_header = [
"Date",
"Montant",
"Devise",
"Contrepartie",
"Compte contrepartie",
"Type d'opération",
"Communication",
"Compte donneur d'ordre",
]
def _generate_note_crelan(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)
notes.append(
"{}: {}".format(_("Counter Party Name"), move[COUNTERPART_NAME])
)
notes.append(
"{}: {}".format(_("Counter Party Account"), move[COUNTERPART_NUMBER])
)
notes.append("{}: {}".format(_("Communication"), move[COMMUNICATION]))
return "\n".join(notes)
def _get_move_value_crelan(self, move, sequence):
move_data = {
'name': move[TRANSACTION_TYPE] + ": " + move[COMMUNICATION],
'note': self._generate_note_crelan(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] + '-' + hashlib.new('md5', move[COMMUNICATION].encode()).hexdigest()
"name": move[TRANSACTION_TYPE] + ": " + move[COMMUNICATION],
"note": self._generate_note_crelan(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]
+ "-"
+ hashlib.new("md5", move[COMMUNICATION].encode()).hexdigest(),
}
return move_data
def _get_statement_data_crelan(self, balance_start, balance_end, begin_date, end_date):
def _get_statement_data_crelan(
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' : []
"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_crelan(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)])
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_crelan(self, acc_number):
if not self.init_balance == None:
return self.init_balance
journal = self.env['account.journal'].search([('bank_acc_number', '=like', '%' + acc_number)])
journal = self.env["account.journal"].search(
[("bank_acc_number", "=like", "%" + acc_number)]
)
currency = journal.currency_id or journal.company_id.currency_id
if not journal or len(journal) > 1: # If not found or ambiguious
self.init_balance = 0.0
else:
lang = self._context.get('lang', 'en_US')
l = self.env['res.lang'].search([('code', '=', lang)])
balance = journal.get_journal_dashboard_datas()['last_balance'][:-1]
self.init_balance = float(balance.replace(currency.symbol, '').strip().replace(l.thousands_sep, '').replace(l.decimal_point, '.'))
lang = self._context.get("lang", "en_US")
l = self.env["res.lang"].search([("code", "=", lang)])
balance = journal.get_journal_dashboard_datas()["last_balance"][
:-1
]
self.init_balance = float(
balance.replace(currency.symbol, "")
.strip()
.replace(l.thousands_sep, "")
.replace(l.decimal_point, ".")
)
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')
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.decode())
data = csv.DictReader(csv_file, delimiter=self._csv_delimiter, quotechar=self._csv_quote)
data = csv.DictReader(
csv_file,
delimiter=self._csv_delimiter,
quotechar=self._csv_quote,
)
if not data.fieldnames == self._header:
raise ValueError()
except ValueError:
@ -113,6 +156,12 @@ class CodaBankStatementImport(models.TransientModel):
transactions.append(self._get_move_value_crelan(statement, i))
sum_transaction += float(statement[AMOUNT])
i += 1
stmt = self._get_statement_data_crelan(balance, balance + sum_transaction, begin_date, end_date)
stmt['transactions'] = transactions
return currency_code, self._get_acc_number_crelan(account_number), [stmt]
stmt = self._get_statement_data_crelan(
balance, balance + sum_transaction, begin_date, end_date
)
stmt["transactions"] = transactions
return (
currency_code,
self._get_acc_number_crelan(account_number),
[stmt],
)

47
beesdoo_easy_my_coop/__manifest__.py

@ -1,35 +1,28 @@
{
'name': "Beescoop link with easy my coop",
'summary': """
"name": "Beescoop link with easy my coop",
"summary": """
Module that made the link between beesdoo customization
and easy_my_coop
""",
'description': """
"description": """
""",
'author': "BEES coop, Coop IT Easy",
'website': "https://github.com/beescoop/Obeesdoo",
'category': 'Cooperative management',
'version': '12.0.1.0.0',
'depends': ['beesdoo_base',
'beesdoo_shift',
'easy_my_coop',
'easy_my_coop_website',
'partner_age',
],
'data': [
'views/res_company.xml',
'views/subscription_request.xml',
'views/subscription_templates.xml',
'views/product.xml'
"author": "BEES coop, Coop IT Easy",
"website": "https://github.com/beescoop/Obeesdoo",
"category": "Cooperative management",
"version": "12.0.1.0.0",
"depends": [
"beesdoo_base",
"beesdoo_shift",
"easy_my_coop",
"easy_my_coop_website",
"partner_age",
],
'demo': [
'demo/product_share.xml',
"data": [
"views/res_company.xml",
"views/subscription_request.xml",
"views/subscription_templates.xml",
"views/product.xml",
],
'auto_install': True,
"demo": ["demo/product_share.xml"],
"auto_install": True,
}

27
beesdoo_easy_my_coop/controllers/main.py

@ -1,19 +1,22 @@
from odoo import http
from odoo.http import request
from odoo.addons.easy_my_coop_website.controllers.main import WebsiteSubscription as Base
from odoo.addons.easy_my_coop_website.controllers.main import (
WebsiteSubscription as Base,
)
class WebsiteSubscription(Base):
class WebsiteSubscription(Base):
def fill_values(self, values, is_company, logged, load_from_user=False):
values = super(WebsiteSubscription, self).fill_values(values,
is_company,
logged,
load_from_user)
cmp = request.env['res.company']._company_default_get()
values.update({
'display_info_session': cmp.display_info_session_confirmation,
'info_session_required': cmp.info_session_confirmation_required,
'info_session_text': cmp.info_session_confirmation_text,
})
values = super(WebsiteSubscription, self).fill_values(
values, is_company, logged, load_from_user
)
cmp = request.env["res.company"]._company_default_get()
values.update(
{
"display_info_session": cmp.display_info_session_confirmation,
"info_session_required": cmp.info_session_confirmation_required,
"info_session_text": cmp.info_session_confirmation_text,
}
)
return values

8
beesdoo_easy_my_coop/models/product.py

@ -1,9 +1,9 @@
from odoo import models, fields
from odoo import fields, models
class ProductTemplate(models.Model):
_inherit = 'product.template'
_inherit = "product.template"
max_nb_eater_allowed = fields.Integer(
string="Max number of eater allowed",
@ -11,14 +11,14 @@ class ProductTemplate(models.Model):
help=(
"Maximum number of eater allowed for the owner of the share. "
"A negative value means no maximum."
)
),
)
allow_working = fields.Boolean(
string="Allow owner to work?",
help=(
"Owner of this type of share are allowed to participate to the "
"shift system."
)
),
)
allow_shopping = fields.Boolean(
string="Allow owner to shop?",

20
beesdoo_easy_my_coop/models/res_company.py

@ -1,12 +1,12 @@
# Copyright 2019 Coop IT Easy SCRLfs
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models, _
from odoo import _, api, fields, models
class ResCompany(models.Model):
_inherit = 'res.company'
_inherit = "res.company"
display_info_session_confirmation = fields.Boolean(
help="Choose to display a info session checkbox on the cooperator"
" website form."
@ -17,19 +17,21 @@ class ResCompany(models.Model):
info_session_confirmation_text = fields.Html(
translate=True,
help="Text to display aside the checkbox to confirm"
" participation to an info session."
" participation to an info session.",
)
@api.onchange('info_session_confirmation_required')
@api.onchange("info_session_confirmation_required")
def onchange_info_session_confirmatio_required(self):
if self.info_session_confirmation_required:
self.display_info_session_confirmation = True
_sql_constraints = [(
'info_session_approval_constraint',
"""CHECK ((info_session_confirmation_required=FALSE
_sql_constraints = [
(
"info_session_approval_constraint",
"""CHECK ((info_session_confirmation_required=FALSE
AND display_info_session_confirmation=FALSE)
OR display_info_session_confirmation=TRUE)
""",
"Approval can't be mandatory and not displayed."
)]
"Approval can't be mandatory and not displayed.",
)
]

40
beesdoo_easy_my_coop/models/res_partner.py

@ -1,22 +1,21 @@
# Copyright 2019-2020 Coop IT Easy SCRLfs
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api, _
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class Partner(models.Model):
_inherit = 'res.partner'
_inherit = "res.partner"
info_session_confirmed = fields.Boolean(
string="Confirmed presence to info session",
default=False,
string="Confirmed presence to info session", default=False
)
is_worker = fields.Boolean(
compute="_is_worker",
search="_search_worker",
readonly=True,
related=""
related="",
)
def _cooperator_share_type(self):
@ -27,16 +26,17 @@ class Partner(models.Model):
share_type = None
if self.cooperator_type:
share_type = (
self.env['product.template']
.search([('default_code', '=', self.cooperator_type)])
self.env["product.template"].search(
[("default_code", "=", self.cooperator_type)]
)
)[0]
return share_type
@api.depends(
'share_ids',
'share_ids.share_product_id',
'share_ids.share_product_id.default_code',
'share_ids.share_number',
"share_ids",
"share_ids.share_product_id",
"share_ids.share_product_id.default_code",
"share_ids.share_number",
)
def _is_worker(self):
"""
@ -53,7 +53,7 @@ class Partner(models.Model):
rec.worker_store = False
def _search_worker(self, operator, value):
return [('worker_store', operator, value)]
return [("worker_store", operator, value)]
@api.depends(
"cooperative_status_ids",
@ -79,10 +79,11 @@ class Partner(models.Model):
else:
rec.can_shop = (
rec.cooperative_status_ids.can_shop
if rec.is_worker and rec.cooperative_status_ids else False
if rec.is_worker and rec.cooperative_status_ids
else False
)
@api.constrains('parent_eater_id')
@api.constrains("parent_eater_id")
def _check_max_parent_eaters(self):
"""
Check that the parent_eater_id in parnter in self doesn't exceed
@ -95,16 +96,15 @@ class Partner(models.Model):
if (
share_type
and share_type.max_nb_eater_allowed >= 0
and len(
rec.parent_eater_id.child_eater_ids
) > share_type.max_nb_eater_allowed
and len(rec.parent_eater_id.child_eater_ids)
> share_type.max_nb_eater_allowed
):
raise ValidationError(
_('You can only set %d additional eaters per worker')
_("You can only set %d additional eaters per worker")
% share_type.max_nb_eater_allowed
)
@api.constrains('child_eater_ids')
@api.constrains("child_eater_ids")
def _check_max_child_eaters(self):
"""
Check the maximum number of eaters that can be assigned to a
@ -119,6 +119,6 @@ class Partner(models.Model):
and len(rec.child_eater_ids) > share_type.max_nb_eater_allowed
):
raise ValidationError(
_('You can only set %d additional eaters per worker')
_("You can only set %d additional eaters per worker")
% share_type.max_nb_eater_allowed
)

13
beesdoo_easy_my_coop/models/subscription_request.py

@ -1,26 +1,25 @@
# Copyright 2019 Coop IT Easy SCRLfs
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models, _
from odoo import _, api, fields, models
class SubscriptionRequest(models.Model):
_inherit = 'subscription.request'
_inherit = "subscription.request"
info_session_confirmed = fields.Boolean(
string="Confirmed Info Session",
default=False,
string="Confirmed Info Session", default=False
)
def get_partner_vals(self):
partner_vals = super(SubscriptionRequest, self).get_partner_vals()
partner_vals['info_session_confirmed'] = self.info_session_confirmed
partner_vals["info_session_confirmed"] = self.info_session_confirmed
return partner_vals
def get_required_field(self):
required_fields = super(SubscriptionRequest, self).get_required_field()
company = self.env['res.company']._company_default_get()
company = self.env["res.company"]._company_default_get()
if company.info_session_confirmation_required:
required_fields.append('info_session_confirmed')
required_fields.append("info_session_confirmed")
return required_fields

50
beesdoo_easy_my_coop/tests/test_res_partner.py

@ -19,9 +19,7 @@ class TestResPartner(TransactionCase):
Test adding eater to a cooperator and raise when max is
reached.
"""
coop1 = self.env.ref(
"beesdoo_base.res_partner_cooperator_1_demo"
)
coop1 = self.env.ref("beesdoo_base.res_partner_cooperator_1_demo")
coop1.write({"child_eater_ids": [(4, self.eater1.id)]})
self.assertEqual(len(coop1.child_eater_ids), 1)
coop1.write({"child_eater_ids": [(4, self.eater2.id)]})
@ -50,9 +48,7 @@ class TestResPartner(TransactionCase):
Test adding eater to a cooperator and raise when max is
reached.
"""
coop2 = self.env.ref(
"beesdoo_base.res_partner_cooperator_2_demo"
)
coop2 = self.env.ref("beesdoo_base.res_partner_cooperator_2_demo")
coop2.write({"child_eater_ids": [(4, self.eater1.id)]})
self.assertEqual(len(coop2.child_eater_ids), 1)
coop2.write({"child_eater_ids": [(4, self.eater2.id)]})
@ -76,9 +72,7 @@ class TestResPartner(TransactionCase):
"""
Test that share_c can have an unlimited number of eater.
"""
coop3 = self.env.ref(
"beesdoo_base.res_partner_cooperator_3_demo"
)
coop3 = self.env.ref("beesdoo_base.res_partner_cooperator_3_demo")
coop3.write({"child_eater_ids": [(4, self.eater1.id)]})
self.assertEqual(len(coop3.child_eater_ids), 1)
coop3.write({"child_eater_ids": [(4, self.eater2.id)]})
@ -94,9 +88,7 @@ class TestResPartner(TransactionCase):
"""
share_c = self.env.ref("beesdoo_easy_my_coop.share_c")
share_c.max_nb_eater_allowed = 0
coop3 = self.env.ref(
"beesdoo_base.res_partner_cooperator_3_demo"
)
coop3 = self.env.ref("beesdoo_base.res_partner_cooperator_3_demo")
with self.assertRaises(ValidationError) as econtext:
coop3.write({"child_eater_ids": [(4, self.eater3.id)]})
self.assertIn("can only set", str(econtext.exception))
@ -108,9 +100,7 @@ class TestResPartner(TransactionCase):
"""
Test adding multiple eater in one write.
"""
coop1 = self.env.ref(
"beesdoo_base.res_partner_cooperator_1_demo"
)
coop1 = self.env.ref("beesdoo_base.res_partner_cooperator_1_demo")
coop1.write(
{
"child_eater_ids": [
@ -126,9 +116,7 @@ class TestResPartner(TransactionCase):
"""
Test adding a parent to multiple eater in one write from the eater.
"""
coop1 = self.env.ref(
"beesdoo_base.res_partner_cooperator_1_demo"
)
coop1 = self.env.ref("beesdoo_base.res_partner_cooperator_1_demo")
eaters = self.eater1
eaters |= self.eater2
eaters |= self.eater3
@ -139,9 +127,7 @@ class TestResPartner(TransactionCase):
"""
Test that a cooperator is a worker based on his share type.
"""
coop1 = self.env.ref(
"beesdoo_base.res_partner_cooperator_1_demo"
)
coop1 = self.env.ref("beesdoo_base.res_partner_cooperator_1_demo")
# Run computed field
coop1._is_worker()
self.assertEqual(coop1.is_worker, True)
@ -150,9 +136,7 @@ class TestResPartner(TransactionCase):
"""
Test that a cooperator is a worker based on his share type.
"""
coop2 = self.env.ref(
"beesdoo_base.res_partner_cooperator_2_demo"
)
coop2 = self.env.ref("beesdoo_base.res_partner_cooperator_2_demo")
# Run computed field
coop2._is_worker()
self.assertEqual(coop2.is_worker, False)
@ -162,12 +146,8 @@ class TestResPartner(TransactionCase):
Test that the search function returns worker based on the
'is_worker' field.
"""
coop1 = self.env.ref(
"beesdoo_base.res_partner_cooperator_1_demo"
)
coop2 = self.env.ref(
"beesdoo_base.res_partner_cooperator_2_demo"
)
coop1 = self.env.ref("beesdoo_base.res_partner_cooperator_1_demo")
coop2 = self.env.ref("beesdoo_base.res_partner_cooperator_2_demo")
# Run computed field
coop1._is_worker()
coop2._is_worker()
@ -182,14 +162,12 @@ class TestResPartner(TransactionCase):
"""
Test that a cooperator can shop based on his share type.
"""
coop1 = self.env.ref(
"beesdoo_base.res_partner_cooperator_1_demo"
)
coop1 = self.env.ref("beesdoo_base.res_partner_cooperator_1_demo")
# Run computed field
coop1._compute_can_shop()
self.assertEqual(coop1.can_shop, True)
# Now unsubscribe the coop
coop1.cooperative_status_ids.status = 'resigning'
coop1.cooperative_status_ids.status = "resigning"
self.assertEqual(coop1.cooperative_status_ids.can_shop, False)
self.assertEqual(coop1.can_shop, False)
@ -197,9 +175,7 @@ class TestResPartner(TransactionCase):
"""
Test that a cooperator can shop based on his share type.
"""
coop3 = self.env.ref(
"beesdoo_base.res_partner_cooperator_3_demo"
)
coop3 = self.env.ref("beesdoo_base.res_partner_cooperator_3_demo")
# Run computed field
coop3._compute_can_shop()
self.assertEqual(coop3.can_shop, False)

13
beesdoo_easy_my_coop/wizards/beesdoo_shift_subscribe.py

@ -1,12 +1,12 @@
# Copyright 2019 Coop IT Easy SCRLfs
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models, _
from odoo import _, api, fields, models
class Subscribe(models.TransientModel):
_inherit = 'beesdoo.shift.subscribe'
_inherit = "beesdoo.shift.subscribe"
def _get_info_session_followed(self):
"""
@ -15,10 +15,11 @@ class Subscribe(models.TransientModel):
"""
followed = super(Subscribe, self)._get_info_session_followed()
if not followed:
return (self.env['res.partner']
.browse(self._context.get('active_id'))
.info_session_confirmed)
return (
self.env["res.partner"]
.browse(self._context.get("active_id"))
.info_session_confirmed
)
return followed
info_session = fields.Boolean(default=_get_info_session_followed)

25
beesdoo_inventory/__manifest__.py

@ -5,23 +5,18 @@
# - Jean-Marc François
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "Beesdoo Inventory",
'summary': """
"name": "Beesdoo Inventory",
"summary": """
Adds a responsible, a max shipping date and a button to copy quantity to
stock pickings.""",
'description': """
"description": """
""",
'author': "Beescoop - Cellule IT",
'website': "https://github.com/beescoop/Obeesdoo",
'category': 'Inventory',
'version': '12.0.1.0.0',
'depends': ['delivery', 'beesdoo_base', 'beesdoo_product'],
'data': [
'views/stock.xml'
],
'installable': True,
"author": "Beescoop - Cellule IT",
"website": "https://github.com/beescoop/Obeesdoo",
"category": "Inventory",
"version": "12.0.1.0.0",
"depends": ["delivery", "beesdoo_base", "beesdoo_product"],
"data": ["views/stock.xml"],
"installable": True,
}

43
beesdoo_inventory/models/stock.py

@ -1,21 +1,40 @@
from odoo import _, api, fields, models
from odoo import _, api, fields, models
class StockPicking(models.Model):
_inherit = 'stock.picking'
_inherit = "stock.picking"
max_shipping_date = fields.Datetime("End Shipping Date")
responsible = fields.Many2one('res.partner', string="Responsible", default=lambda self: self.env.user.partner_id.id)
responsible = fields.Many2one(
"res.partner",
string="Responsible",
default=lambda self: self.env.user.partner_id.id,
)
def _add_follower(self):
if(self.responsible):
types = self.env['mail.message.subtype'].search(['|',('res_model','=','stock.picking'),('name','=','Discussions')])
if not self.env['mail.followers'].search([('res_id', '=', self.id),
('res_model', '=', 'stock.picking'),
('partner_id', '=', self.responsible.id)]):
self.env['mail.followers'].create({'res_model' : 'stock.picking',
'res_id' : self.id,
'partner_id' : self.responsible.id,
'subtype_ids': [(6, 0, types.ids)]})
if self.responsible:
types = self.env["mail.message.subtype"].search(
[
"|",
("res_model", "=", "stock.picking"),
("name", "=", "Discussions"),
]
)
if not self.env["mail.followers"].search(
[
("res_id", "=", self.id),
("res_model", "=", "stock.picking"),
("partner_id", "=", self.responsible.id),
]
):
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):

2
beesdoo_inventory/readme/CONTRIBUTORS.rst

@ -0,0 +1,2 @@
* Beescoop - Cellule IT
* Coop IT Easy SCRLfs

2
beesdoo_pos/__init__.py

@ -1 +1 @@
from . import models
from . import models

32
beesdoo_pos/__manifest__.py

@ -6,29 +6,19 @@
# - Grégoire Leeuwerck
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "Beescoop Point of sale",
'summary': """
"name": "Beescoop Point of sale",
"summary": """
Module that extends the pos for the beescoop
""",
'description': """
"description": """
This module adds the eaters of the customer to the POS ActionpadWidget and PaymentScreenWidget.
""",
'author': "Beescoop - Cellule IT",
'website': "https://github.com/beescoop/Obeesdoo",
'category': 'Point Of Sale',
'version': '12.0.1.0.0',
'depends': ['beesdoo_base', 'beesdoo_product'],
'data': [
'views/beesdoo_pos.xml',
'data/default_barcode_pattern.xml',
],
'qweb': ['static/src/xml/templates.xml'],
'installable': True,
"author": "Beescoop - Cellule IT",
"website": "https://github.com/beescoop/Obeesdoo",
"category": "Point Of Sale",
"version": "12.0.1.0.0",
"depends": ["beesdoo_base", "beesdoo_product"],
"data": ["views/beesdoo_pos.xml", "data/default_barcode_pattern.xml",],
"qweb": ["static/src/xml/templates.xml"],
"installable": True,
}

2
beesdoo_pos/models/__init__.py

@ -1 +1 @@
from . import beesdoo_pos
from . import beesdoo_pos

4
beesdoo_pos/models/beesdoo_pos.py

@ -1,8 +1,8 @@
from odoo import models, api
from odoo import api, models
class BeescoopPosPartner(models.Model):
_inherit = 'res.partner'
_inherit = "res.partner"
def _get_eater(self):
eaters = [False, False, False]

2
beesdoo_pos/readme/CONTRIBUTORS.rst

@ -0,0 +1,2 @@
* Beescoop - Cellule IT
* Coop IT Easy SCRLfs

2
beesdoo_pos/static/src/css/beesdoo.css

@ -31,4 +31,4 @@
.pos .actionpad .button.pay {
height: 108px;
}
}

2
beesdoo_pos_reporting/models/res_partner.py

@ -4,4 +4,4 @@ from odoo import fields, models
class ResPartner(models.Model):
_inherit = "res.partner"
pos_order_count = fields.Integer(store=True,)
pos_order_count = fields.Integer(store=True)

2
beesdoo_pos_reporting/readme/CONTRIBUTORS.rst

@ -0,0 +1,2 @@
* Beescoop - Cellule IT
* Coop IT Easy SCRLfs

38
beesdoo_product/__manifest__.py

<
@ -6,30 +6,26 @@
# - Thibault François
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "beesdoo_product",
'summary': """
"name": "beesdoo_product",
"summary": """
Modification of product module for the needs of beescoop
- SOOO5 - Ajout de label bio/ethique/provenance""",