diff --git a/bemade_fsm/__manifest__.py b/bemade_fsm/__manifest__.py index 4d8603d..76c491a 100644 --- a/bemade_fsm/__manifest__.py +++ b/bemade_fsm/__manifest__.py @@ -27,22 +27,24 @@ 'author': 'Bemade Inc.', 'website': 'http://www.bemade.org', 'license': 'OPL-1', - 'depends': ['project_enterprise', - 'project_forecast', - 'stock', - 'sale', - 'sale_project', - 'sale_stock', - 'sale_planning', - 'worksheet', - 'industry_fsm_stock', - 'industry_fsm_report', - 'industry_fsm_sale_report', - 'bemade_partner_root_ancestor', - 'mail', - ], + 'depends': [ + 'project_enterprise', + 'project_forecast', + 'stock', + 'sale', + 'sale_project', + 'sale_stock', + 'sale_planning', + 'worksheet', + 'industry_fsm_stock', + 'industry_fsm_report', + 'industry_fsm_sale_report', + 'bemade_partner_root_ancestor', + 'mail', + ], 'data': [ - 'data/fsm_data.xml', + # BV: FOR MIGRATION + # 'data/fsm_data.xml', 'views/task_template_views.xml', 'views/equipment.xml', 'security/ir.model.access.csv', @@ -51,8 +53,8 @@ 'views/menus.xml', 'views/task_views.xml', 'views/sale_order_views.xml', - 'reports/worksheet_custom_report_templates.xml', - 'reports/worksheet_custom_reports.xml', + # 'reports/worksheet_custom_report_templates.xml', + # 'reports/worksheet_custom_reports.xml', ], 'assets': { 'web.assets_tests': [ diff --git a/bemade_fsm/models/task.py b/bemade_fsm/models/task.py index c8a65a2..6f26f6f 100644 --- a/bemade_fsm/models/task.py +++ b/bemade_fsm/models/task.py @@ -119,7 +119,7 @@ class Task(models.Model): ]) return self.env['planning.slot'].search(domain) - @api.depends('forecast_hours') + @api.depends('planned_hours') def _compute_planned_dates(self): forecast_data = self._get_related_planning_slots() mapped_data = {} diff --git a/bemade_hide_decimal_on_unit/__manifest__.py b/bemade_hide_decimal_on_unit/__manifest__.py index d0bc66e..ca800a1 100644 --- a/bemade_hide_decimal_on_unit/__manifest__.py +++ b/bemade_hide_decimal_on_unit/__manifest__.py @@ -14,8 +14,9 @@ 'purchase' ], "data": [ - 'views/sale.xml', - 'views/purchase.xml' + # BV : FOR MIGRATION + # 'views/sale.xml', + # 'views/purchase.xml' ], "auto_install": False, "installable": True, diff --git a/bemade_mailcow_integration/models/mail_alias.py b/bemade_mailcow_integration/models/mail_alias.py index 2a69a78..df38063 100644 --- a/bemade_mailcow_integration/models/mail_alias.py +++ b/bemade_mailcow_integration/models/mail_alias.py @@ -6,17 +6,14 @@ class MailAlias(models.Model): mailcow_id = fields.One2many('mail.mailcow.alias', 'alias_id') - @api.model - def create(self, vals): - alias = super(MailAlias, self).create(vals) +@api.model_create_multi +def create(self, vals_list): + alias_list = super().create(vals_list) + for alias in alias_list: if not alias.alias_name: - return alias - - alias_domain = self.env["ir.config_parameter"].sudo().get_param("mail.catchall.domain"), - catchall_alias = self.env["ir.config_parameter"].sudo().get_param("mail.catchall.alias"), - - alias_domain = alias_domain[0] - catchall_alias = catchall_alias[0] + continue + alias_domain = self.env["ir.config_parameter"].sudo().get_param("mail.catchall.domain") + catchall_alias = self.env["ir.config_parameter"].sudo().get_param("mail.catchall.alias") if alias_domain: mailcow_alias = self.env['mail.mailcow.alias'].search([('address', '=', alias.alias_name + '@' + alias_domain)]) @@ -28,4 +25,4 @@ class MailAlias(models.Model): 'goto': catchall_alias + '@' + alias_domain, 'alias_id': alias.id, }) - return alias + return alias_list diff --git a/bemade_mailcow_integration/models/mailcow_alias.py b/bemade_mailcow_integration/models/mailcow_alias.py index 560b11b..a4677f1 100644 --- a/bemade_mailcow_integration/models/mailcow_alias.py +++ b/bemade_mailcow_integration/models/mailcow_alias.py @@ -24,11 +24,12 @@ class MailcowAlias(models.Model): ('address_unique', 'UNIQUE(address)', 'The alias address must be unique!'), ] - @api.model - def create(self, vals): - alias = super(MailcowAlias, self).create(vals) +@api.model_create_multi +def create(self, vals_list): + alias_list = super().create(vals_list) + for alias in alias_list: - if 'mc_id' not in vals: + if 'mc_id' not in alias: data = { "active": bool(alias.active), "address": alias.address, @@ -42,7 +43,7 @@ class MailcowAlias(models.Model): #pass raise ValidationError("Failed to create alias on Mailcow server.") - return alias + return alias_list def unlink(self): for record in self: diff --git a/bemade_mailcow_integration/models/mailcow_blacklist.py b/bemade_mailcow_integration/models/mailcow_blacklist.py index 3e3ba81..1389779 100644 --- a/bemade_mailcow_integration/models/mailcow_blacklist.py +++ b/bemade_mailcow_integration/models/mailcow_blacklist.py @@ -6,6 +6,7 @@ import json _logger = logging.getLogger(__name__) + class MailcowBlacklist(models.Model): _name = 'mail.mailcow.blacklist' _description = 'Mailcow Blacklist' @@ -14,30 +15,26 @@ class MailcowBlacklist(models.Model): email = fields.Char(string='Email', required=True, tracking=True) mc_id = fields.Integer(string='Mailcow ID', required=True, tracking=True) - @api.model - def create(self, vals): - """ - Overridden create method to add the new blacklist entry to the Mailcow server. - """ - domain = self.env['ir.config_parameter'].sudo().get_param('mail.catchall.domain') + @api.model_create_multi + def create(self, vals_list): + alias_list = super().create(vals_list) + for alias in alias_list: - endpoint_add = '/api/v1/add/domain-policy' - endpoint_get_bl = f"/api/v1/get/policy_bl_domain/{domain}" - data = { - 'domain': domain, - 'object_from': vals['email'], - 'object_list': 'bl' - } + if 'mc_id' not in alias: + data = { + "active": bool(alias.active), + "address": alias.address, + "catchall": bool(alias.catchall), + "goto": alias.goto, + "private_comment": f"Created by {self.env.user.name} on {fields.Datetime.now()}", + "public_comment": "Alias created in Odoo" + } + result = self.env['mail.mailcow'].api_request('/api/v1/add/alias', 'POST', data) + if not result: + #pass + raise ValidationError("Failed to create alias on Mailcow server.") - self.api_request(endpoint_add, 'POST', data) - _logger.info(f'Added {vals["email"]} to Mailcow blacklist') - - bl_emails = self.api_request(endpoint_get_bl, 'GET', None) - - mc_id = [d['prefid'] for d in bl_emails if d['value'] == vals['email']] - vals['mc_id'] = mc_id[0] - res = super().create(vals) - return res + return alias_list def write(self, vals): """ diff --git a/bemade_mailcow_integration/models/mailcow_mailbox.py b/bemade_mailcow_integration/models/mailcow_mailbox.py index 920db47..f6699e6 100644 --- a/bemade_mailcow_integration/models/mailcow_mailbox.py +++ b/bemade_mailcow_integration/models/mailcow_mailbox.py @@ -47,37 +47,44 @@ class MailcowMailbox(models.Model): 'active': item['active'], }) - @api.model - def create(self, vals): + @api.model_create_multi + def create(self, vals_list): """ - Override the create function to create a Mailcow mailbox whenever a user is created in Odoo. + Overridden create method to add a new mailbox entry on the Mailcow server for each user created in Odoo. """ - password = secrets.token_hex(16) - vals['password'] = password - # Check if email exists on Mailcow - endpoint = f"/api/v1/get/mailbox/{vals['local_part']}@{vals['domain']}" - response = self.api_request(endpoint) + res_list = [] - if not response: - # If email does not exist on Mailcow, create it - endpoint = '/api/v1/add/mailbox' - data = { - 'local_part': vals['local_part'], - 'domain': vals['domain'], - 'name': vals['name'], - 'password': password, - 'password2': password, - 'quota': "3072", - 'active': "1", - 'force_pw_update': "0", - 'tls_enforce_in': "0", - 'tls_enforce_out': "0", - } - self.api_request(endpoint, method='POST', data=data) - _logger.info(f"Mailbox {vals['local_part']}@{vals['domain']} has been created on Mailcow server") + for vals in vals_list: + password = secrets.token_hex(16) + vals['password'] = password - return super().create(vals) + # Check if email exists on Mailcow + endpoint = f"/api/v1/get/mailbox/{vals['local_part']}@{vals['domain']}" + response = self.api_request(endpoint) + + if not response: + # If email does not exist on Mailcow, create it + endpoint = '/api/v1/add/mailbox' + data = { + 'local_part': vals['local_part'], + 'domain': vals['domain'], + 'name': vals['name'], + 'password': password, + 'password2': password, + 'quota': "3072", + 'active': "1", + 'force_pw_update': "0", + 'tls_enforce_in': "0", + 'tls_enforce_out': "0", + } + self.api_request(endpoint, method='POST', data=data) + _logger.info(f"Mailbox {vals['local_part']}@{vals['domain']} has been created on Mailcow server") + + res = super().create(vals) + res_list.append(res) + + return res_list def write(self, vals): """ diff --git a/bemade_mailcow_integration/models/res_users.py b/bemade_mailcow_integration/models/res_users.py index 34f8efb..61e5910 100644 --- a/bemade_mailcow_integration/models/res_users.py +++ b/bemade_mailcow_integration/models/res_users.py @@ -25,12 +25,13 @@ class ResUsers(models.Model): rec.mailcow_auto_create = get_mailcow_auto_create - @api.model - def create(self, vals): - res = super(ResUsers, self).create(vals) + @api.model_create_multi + def create(self, vals_list): + res_list = super().create(vals_list) - if res.mailcow_mailbox: - self.env['mail.mailcow.mailbox'].create_mailbox_for_user(res) + for res in res_list: + if res.mailcow_mailbox: + self.env['mail.mailcow.mailbox'].create_mailbox_for_user(res) - return res + return res_list diff --git a/bemade_reordering_rules_chatter/__manifest__.py b/bemade_reordering_rules_chatter/__manifest__.py index ef89fa1..df72a54 100644 --- a/bemade_reordering_rules_chatter/__manifest__.py +++ b/bemade_reordering_rules_chatter/__manifest__.py @@ -14,7 +14,8 @@ 'stock', ], "data": [ - 'views/stock_warehouse_orderpoint.xml', + # BV : FOR MIGRATION + # 'views/stock_warehouse_orderpoint.xml', ], "auto_install": False, "installable": True, diff --git a/bemade_so_followers_to_picking/models/stock_picking.py b/bemade_so_followers_to_picking/models/stock_picking.py index 48a35b4..2f7bd87 100644 --- a/bemade_so_followers_to_picking/models/stock_picking.py +++ b/bemade_so_followers_to_picking/models/stock_picking.py @@ -4,14 +4,16 @@ from odoo import models, api class StockPicking(models.Model): _inherit = 'stock.picking' - @api.model - def create(self, vals): - picking = super(StockPicking, self).create(vals) +@api.model_create_multi +def create(self, vals_list): + pickings = super().create(vals_list) + + for picking, vals in zip(pickings, vals_list): if 'origin' in vals: sale_order = self.env['sale.order'].search([('name', '=', vals['origin'])], limit=1) if sale_order: for follower in sale_order.message_follower_ids: picking.message_subscribe(partner_ids=[follower.partner_id.id]) - return picking + return pickings diff --git a/bemade_user_password_bundle/models/hr_employee.py b/bemade_user_password_bundle/models/hr_employee.py index 6517fb9..f0d8617 100644 --- a/bemade_user_password_bundle/models/hr_employee.py +++ b/bemade_user_password_bundle/models/hr_employee.py @@ -5,16 +5,17 @@ from odoo import models, fields, api class HrEmployee(models.Model): _inherit = 'hr.employee' - @api.model - def create(self, vals): - newemployee = super(HrEmployee, self).create(vals) - pw_bundle = self.env['password.bundle'].create({ - 'name': newemployee.name, - 'notes': f"Created new employee Password Bundle for {newemployee.name}" - }) - self.env['password.access'].create({ - 'bundle_id': pw_bundle.id, - 'user_id': newemployee.user_id.id, - 'access_level': 'full', - }) - return newemployee \ No newline at end of file + @api.model_create_multi + def create(self, vals_list): + new_employees = super().create(vals_list) + for newemployee in new_employees: + pw_bundle = self.env['password.bundle'].create({ + 'name': newemployee.name, + 'notes': f"Created new employee Password Bundle for {newemployee.name}" + }) + self.env['password.access'].create({ + 'bundle_id': pw_bundle.id, + 'user_id': newemployee.user_id.id, + 'access_level': 'full', + }) + return new_employees \ No newline at end of file