From 5422139cfaa3b524f3a6e0307ffa632c68af3eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20V=C3=A9zina?= Date: Wed, 6 Mar 2024 07:55:38 -0500 Subject: [PATCH 1/9] bemade_total_show_currency --- bemade_total_show_currency/__manifest__.py | 41 +++++++++++++++++++ .../views/total_template.xml | 14 +++++++ 2 files changed, 55 insertions(+) create mode 100644 bemade_total_show_currency/__manifest__.py create mode 100644 bemade_total_show_currency/views/total_template.xml diff --git a/bemade_total_show_currency/__manifest__.py b/bemade_total_show_currency/__manifest__.py new file mode 100644 index 0000000..e020b92 --- /dev/null +++ b/bemade_total_show_currency/__manifest__.py @@ -0,0 +1,41 @@ +# +# Bemade Inc. +# +# Copyright (C) June 2023 Bemade Inc. (). +# Author: mdurepos (Contact : it@bemade.org) +# +# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) +# It is forbidden to publish, distribute, sublicense, or sell copies of the Software +# or modified copies of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +{ + 'name': 'Show Currency in total', + 'version': '15.0.0.0.1', + 'summary': 'Show Currency in total', + 'description': """ + This module adds the ability to view currency in total in all pdf. + """, + 'category': 'Account', + 'author': 'Bemade Inc.', + 'website': 'https://www.bemade.org', + 'license': 'OPL-1', + 'depends': [ + 'sale', + 'purchase', + 'account' + ], + 'data': [ + 'views/total_template.xml' + ], + 'demo': [], + 'installable': True, + 'auto_install': False, +} diff --git a/bemade_total_show_currency/views/total_template.xml b/bemade_total_show_currency/views/total_template.xml new file mode 100644 index 0000000..77a2bf2 --- /dev/null +++ b/bemade_total_show_currency/views/total_template.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file From 988a28a9d31a485f17dc91530b4fd881a4108ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20V=C3=A9zina?= Date: Mon, 11 Mar 2024 14:29:46 -0400 Subject: [PATCH 2/9] quot alt --- bemade_quotation_alternative/__init__.py | 2 +- bemade_quotation_alternative/__manifest__.py | 4 +- .../controllers/__init__.py | 3 - .../controllers/controllers.py | 21 ----- bemade_quotation_alternative/demo/demo.xml | 30 ------- .../models/__init__.py | 2 +- bemade_quotation_alternative/models/models.py | 18 ----- .../models/sale_order.py | 20 ++--- .../security/ir.model.access.csv | 3 +- .../views/sale_order_views.xml | 43 +++++++--- .../views/templates.xml | 24 ------ .../wizard/__init__.py | 3 +- .../sale_oder_line_duplication_wizard.py | 9 +++ .../wizard/sale_order_alternative.py | 59 -------------- .../wizard/sale_order_alternative_views.xml | 45 ----------- .../wizard/sale_order_duplication_wizard.py | 78 +++++++++++++++++++ .../sale_order_duplication_wizard_view.xml | 44 +++++++++++ 17 files changed, 180 insertions(+), 228 deletions(-) delete mode 100644 bemade_quotation_alternative/controllers/__init__.py delete mode 100644 bemade_quotation_alternative/controllers/controllers.py delete mode 100644 bemade_quotation_alternative/demo/demo.xml delete mode 100644 bemade_quotation_alternative/models/models.py delete mode 100644 bemade_quotation_alternative/views/templates.xml create mode 100644 bemade_quotation_alternative/wizard/sale_oder_line_duplication_wizard.py delete mode 100644 bemade_quotation_alternative/wizard/sale_order_alternative.py delete mode 100644 bemade_quotation_alternative/wizard/sale_order_alternative_views.xml create mode 100644 bemade_quotation_alternative/wizard/sale_order_duplication_wizard.py create mode 100644 bemade_quotation_alternative/wizard/sale_order_duplication_wizard_view.xml diff --git a/bemade_quotation_alternative/__init__.py b/bemade_quotation_alternative/__init__.py index 8604020..3c4e748 100644 --- a/bemade_quotation_alternative/__init__.py +++ b/bemade_quotation_alternative/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- from . import wizard -from . import models \ No newline at end of file +from . import models diff --git a/bemade_quotation_alternative/__manifest__.py b/bemade_quotation_alternative/__manifest__.py index 1e2db88..bcb23b9 100644 --- a/bemade_quotation_alternative/__manifest__.py +++ b/bemade_quotation_alternative/__manifest__.py @@ -26,9 +26,9 @@ # always loaded 'data': [ - # 'security/ir.model.access.csv', + 'security/ir.model.access.csv', 'views/sale_order_views.xml', - 'wizard/sale_order_alternative_views.xml', + 'wizard/sale_order_duplication_wizard_view.xml', ], # only loaded in demonstration mode 'demo': [ diff --git a/bemade_quotation_alternative/controllers/__init__.py b/bemade_quotation_alternative/controllers/__init__.py deleted file mode 100644 index 457bae2..0000000 --- a/bemade_quotation_alternative/controllers/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# -*- coding: utf-8 -*- - -from . import controllers \ No newline at end of file diff --git a/bemade_quotation_alternative/controllers/controllers.py b/bemade_quotation_alternative/controllers/controllers.py deleted file mode 100644 index ab78d96..0000000 --- a/bemade_quotation_alternative/controllers/controllers.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# from odoo import http - - -# class .repos/bemade-addons/bemadeQuotationAlternative(http.Controller): -# @http.route('/.repos/bemade-addons/bemade_quotation_alternative/.repos/bemade-addons/bemade_quotation_alternative', auth='public') -# def index(self, **kw): -# return "Hello, world" - -# @http.route('/.repos/bemade-addons/bemade_quotation_alternative/.repos/bemade-addons/bemade_quotation_alternative/objects', auth='public') -# def list(self, **kw): -# return http.request.render('.repos/bemade-addons/bemade_quotation_alternative.listing', { -# 'root': '/.repos/bemade-addons/bemade_quotation_alternative/.repos/bemade-addons/bemade_quotation_alternative', -# 'objects': http.request.env['.repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative'].search([]), -# }) - -# @http.route('/.repos/bemade-addons/bemade_quotation_alternative/.repos/bemade-addons/bemade_quotation_alternative/objects/', auth='public') -# def object(self, obj, **kw): -# return http.request.render('.repos/bemade-addons/bemade_quotation_alternative.object', { -# 'object': obj -# }) diff --git a/bemade_quotation_alternative/demo/demo.xml b/bemade_quotation_alternative/demo/demo.xml deleted file mode 100644 index e9046ff..0000000 --- a/bemade_quotation_alternative/demo/demo.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - \ No newline at end of file diff --git a/bemade_quotation_alternative/models/__init__.py b/bemade_quotation_alternative/models/__init__.py index 3e8b8f8..6064afe 100644 --- a/bemade_quotation_alternative/models/__init__.py +++ b/bemade_quotation_alternative/models/__init__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -from . import sale_order \ No newline at end of file +from . import sale_order diff --git a/bemade_quotation_alternative/models/models.py b/bemade_quotation_alternative/models/models.py deleted file mode 100644 index 3e82283..0000000 --- a/bemade_quotation_alternative/models/models.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- - -# from odoo import models, fields, api - - -# class .repos/bemade-addons/bemade_quotation_alternative(models.Model): -# _name = '.repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative' -# _description = '.repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative' - -# name = fields.Char() -# value = fields.Integer() -# value2 = fields.Float(compute="_value_pc", store=True) -# description = fields.Text() -# -# @api.depends('value') -# def _value_pc(self): -# for record in self: -# record.value2 = float(record.value) / 100 diff --git a/bemade_quotation_alternative/models/sale_order.py b/bemade_quotation_alternative/models/sale_order.py index 50498d9..c5bb2dd 100644 --- a/bemade_quotation_alternative/models/sale_order.py +++ b/bemade_quotation_alternative/models/sale_order.py @@ -1,17 +1,13 @@ from odoo import fields, models, api -class ModelName(models.Model): +class SaleOrder(models.Model): _inherit = 'sale.order' - def action_create_alternative(self): - return { - 'name': 'Create Alternative', - 'type': 'ir.actions.act_window', - 'res_model': 'bemade.quotation.alternative', - 'view_mode': 'form', - 'target': 'new', - 'context': { - 'default_sale_order_id': self.id, - } - } \ No newline at end of file + def action_duplicate_order(self): + self.ensure_one() + action = self.env.ref('bemade_quotation_alternative.sale_order_duplication_wizard_action').read()[0] + action['context'] = { + 'default_original_order_id': self.id, + } + return action diff --git a/bemade_quotation_alternative/security/ir.model.access.csv b/bemade_quotation_alternative/security/ir.model.access.csv index a531b67..29adc9a 100644 --- a/bemade_quotation_alternative/security/ir.model.access.csv +++ b/bemade_quotation_alternative/security/ir.model.access.csv @@ -1,2 +1,3 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_.repos/bemade-addons/bemade_quotation_alternative_.repos/bemade-addons/bemade_quotation_alternative,.repos/bemade-addons/bemade_quotation_alternative..repos/bemade-addons/bemade_quotation_alternative,model_.repos/bemade-addons/bemade_quotation_alternative_.repos/bemade-addons/bemade_quotation_alternative,base.group_user,1,1,1,1 \ No newline at end of file +bemade_quotation_alternative.access_sale_order_duplication_wizard,access_sale_order_duplication_wizard,bemade_quotation_alternative.model_sale_order_duplication_wizard,base.group_user,1,1,1,1 +bemade_quotation_alternative.access_sale_order_line_duplication_wizard,access_sale_order_line_duplication_wizard,bemade_quotation_alternative.model_sale_order_line_duplication_wizard,base.group_user,1,1,1,1 diff --git a/bemade_quotation_alternative/views/sale_order_views.xml b/bemade_quotation_alternative/views/sale_order_views.xml index c28516e..060f116 100644 --- a/bemade_quotation_alternative/views/sale_order_views.xml +++ b/bemade_quotation_alternative/views/sale_order_views.xml @@ -1,17 +1,40 @@ + + sale.order.form.inherit + sale.order + + +
+
+
+
+ + + + + + + + - - bemade_quotation_alternative form - sale.order - - -
-
-
-
+ + + + + + + + + + -
-
\ No newline at end of file diff --git a/bemade_quotation_alternative/wizard/__init__.py b/bemade_quotation_alternative/wizard/__init__.py index ca94d45..c8bd2b8 100644 --- a/bemade_quotation_alternative/wizard/__init__.py +++ b/bemade_quotation_alternative/wizard/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- -from . import sale_order_alternative \ No newline at end of file +from . import sale_order_duplication_wizard +from . import sale_oder_line_duplication_wizard diff --git a/bemade_quotation_alternative/wizard/sale_oder_line_duplication_wizard.py b/bemade_quotation_alternative/wizard/sale_oder_line_duplication_wizard.py new file mode 100644 index 0000000..c21a696 --- /dev/null +++ b/bemade_quotation_alternative/wizard/sale_oder_line_duplication_wizard.py @@ -0,0 +1,9 @@ +from odoo import models, fields + +class SaleOrderLineDuplicationWizard(models.TransientModel): + _name = 'sale.order.line.duplication.wizard' + _description = 'Wizard for selecting sale order lines to duplicate' + + wizard_id = fields.Many2one('sale.order.duplication.wizard', required=True, ondelete='cascade', string="Wizard") + sale_order_line_id = fields.Many2one('sale.order.line', string="Sale Order Line", required=True) + to_duplicate = fields.Boolean(string="Duplicate?", default=True) diff --git a/bemade_quotation_alternative/wizard/sale_order_alternative.py b/bemade_quotation_alternative/wizard/sale_order_alternative.py deleted file mode 100644 index 9b2b92b..0000000 --- a/bemade_quotation_alternative/wizard/sale_order_alternative.py +++ /dev/null @@ -1,59 +0,0 @@ -from odoo import fields, models, api -import string - - -class AlternativeQuotation(models.TransientModel): - _name = 'sale.order.alternative' - _description = 'Quotation Alternative' - - name = fields.Char() - original_sale_order_id = fields.Many2one('sale.order') - - clone_all_lines = fields.Boolean('Clone all lines', default=True) - origin = fields.Text('Why this alternative ?') - internal_note = fields.Text('Internal Note') - - def action_create_alternative(self): - name = self.original_sale_order_id.name - - if name and name[-1] not in string.ascii_letters: - self.original_sale_order_id.name = name + "A" - name = self.name + "B" - else: - # Assuming 'all_names' is a list of all names - # Add a domain to filter names starting with 'name' (less the last letter) - all_names = [record.name for record in self.env['sale.order'].search([('name', 'like', name[:-1] + '%')])] - if name in all_names: - # Get the index of the current name in the list - index = all_names.index(name) - # If this is not the last name in the list, get the next one - if index < len(all_names) - 1: - name = all_names[index + 1] - else: - # If this is the last name, just add 'B' to it - name = name + "B" - - new_quot = quot.original_sale_order_id.copy({ - 'name': quot.name, - 'origin': quot.original_sale_order_id.name, - 'alternative_sale_order_id': quot.original_sale_order_id.id, - 'alternative': True, - 'alternative_origine': quot.origine, - 'alternative_internal_note': quot.internal_note, - -# # Lines and line based computes -# order_line = fields.One2many( -# comodel_name='sale.order.alternative.line', -# inverse_name='order_id', -# string="Order Lines", -# copy=True, auto_join=True) -# -# class AlternativeQuotation(models.TransientModel): -# _name = 'sale.order.alternative.line' -# # _inherit = 'sale.order.line' -# _description = 'Quotation Alternative Line' -# -# order_id = fields.Many2one( -# comodel_name='sale.order.alternative', -# string="Alternative Quotation Reference", -# required=True, ondelete='cascade', index=True, copy=False) diff --git a/bemade_quotation_alternative/wizard/sale_order_alternative_views.xml b/bemade_quotation_alternative/wizard/sale_order_alternative_views.xml deleted file mode 100644 index 1c0f07a..0000000 --- a/bemade_quotation_alternative/wizard/sale_order_alternative_views.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - bemade_quotation_alternative.sale_order_alternative.form - sale.order.alternative - -
- -
-
- - - - - - - -
-
-
-
- - - - - - - - - - - - - - - - -
-
\ No newline at end of file diff --git a/bemade_quotation_alternative/wizard/sale_order_duplication_wizard.py b/bemade_quotation_alternative/wizard/sale_order_duplication_wizard.py new file mode 100644 index 0000000..a4e070b --- /dev/null +++ b/bemade_quotation_alternative/wizard/sale_order_duplication_wizard.py @@ -0,0 +1,78 @@ +from odoo import models, fields, api + +class SaleOrderDuplicationWizard(models.TransientModel): + _name = 'sale.order.duplication.wizard' + _description = 'Wizard for duplicating a sale order' + + original_order_id = fields.Many2one('sale.order', string='Original Order', required=True) + new_quot = fields.Char(string='New Quotation Name', compute='_compute_new_quot', store=True) + + duplicate_all_lines = fields.Boolean(string='Duplicate All Lines?', default=True) + lines_to_duplicate = fields.One2many( + 'sale.order.line.duplication.wizard', 'wizard_id', + string="Lines to Duplicate", + context={'default_original_order_id': original_order_id}, + ) + + purpose = fields.Text(string='Purpose') + note = fields.Html(string='Note') + + @api.model + def default_get(self, fields_list): + res = super(SaleOrderDuplicationWizard, self).default_get(fields_list) + if 'default_original_order_id' in self.env.context: + original_order_id = self.env.context['default_original_order_id'] + original_order = self.env['sale.order'].browse(original_order_id) + lines_vals = [] + for line in original_order.order_line: + lines_vals.append((0, 0, {'sale_order_line_id': line.id})) + res.update({ + 'lines_to_duplicate': lines_vals, + 'purpose': original_order.purpose if 'purpose' in fields_list else '', + 'note': original_order.note if 'note' in fields_list else '', + }) + return res + + def action_duplicate_order(self): + self.ensure_one() + # Duplication de la commande de vente + new_order = self.original_order_id.copy({ + 'purpose': self.purpose, + 'note': self.note, + # Assurez-vous que 'new_quot' est défini correctement dans votre modèle + 'name': self.new_quot, + }) + if not self.duplicate_all_lines: + new_order.order_line.unlink() + for line_wiz in self.lines_to_duplicate.filtered('to_duplicate'): + line_wiz.sale_order_line_id.copy({'order_id': new_order.id}) + + # Préparation et envoi des messages de notification dans le chatter + user_name = self.env.user.name + now = fields.Datetime.now() + + # Message pour la commande originale + original_msg_body = f"A new quotation #{new_order.name} created by {user_name} duplicating this Quotation." + self.original_order_id.message_post(body=original_msg_body) + + # Message pour la nouvelle commande dupliquée + new_msg_body = f"This quotation has been created by {user_name} duplicating the original Quotation #{self.original_order_id.name}." + new_order.message_post(body=new_msg_body) + + return { + 'type': 'ir.actions.act_window', + 'name': 'Duplicated Order', + 'res_model': 'sale.order', + 'res_id': new_order.id, + 'view_mode': 'form', + 'target': 'current', + } + + @api.depends('original_order_id') + def _compute_new_quot(self): + + for rec in self: + original_order_name = rec.original_order_id.name.split('-')[ + 0] if '-' in rec.original_order_id.name else rec.original_order_id.name + other_quotes = self.env['sale.order'].search([('name', 'like', original_order_name + '%')]) + rec.new_quot = original_order_name + '-REV' + str(len(other_quotes)) diff --git a/bemade_quotation_alternative/wizard/sale_order_duplication_wizard_view.xml b/bemade_quotation_alternative/wizard/sale_order_duplication_wizard_view.xml new file mode 100644 index 0000000..81cb710 --- /dev/null +++ b/bemade_quotation_alternative/wizard/sale_order_duplication_wizard_view.xml @@ -0,0 +1,44 @@ + + + + + + sale.order.duplication.wizard.form + sale.order.duplication.wizard + +
+ + + + + + + + + + + + + + + + + +
+
+ +
+
+ + + Duplicate Sale Order + ir.actions.act_window + sale.order.duplication.wizard + form + new + + +
+
\ No newline at end of file From 656df081a153293cbfcab21d2d3b5aa118d6dba6 Mon Sep 17 00:00:00 2001 From: Marc Durepos Date: Tue, 12 Mar 2024 11:51:32 -0400 Subject: [PATCH 3/9] Fixes to bemade_mail_cow_integration config param usage. --- bemade_mailcow_integration/__manifest__.py | 2 +- .../migrations/15.0.1.0.1/pre-migrate.py | 13 +++++++++++++ bemade_mailcow_integration/models/mail_alias.py | 6 +++++- .../models/res_config_settings.py | 9 ++++++++- 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 bemade_mailcow_integration/migrations/15.0.1.0.1/pre-migrate.py diff --git a/bemade_mailcow_integration/__manifest__.py b/bemade_mailcow_integration/__manifest__.py index 14c39bb..b54ee6a 100644 --- a/bemade_mailcow_integration/__manifest__.py +++ b/bemade_mailcow_integration/__manifest__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- { 'name': 'Mailcow Integration', - 'version': '1.0.0', + 'version': '15.0.1.0.1', 'category': 'Administration', 'summary': 'Module for integrating Mailcow email server with Odoo.', 'description': """ diff --git a/bemade_mailcow_integration/migrations/15.0.1.0.1/pre-migrate.py b/bemade_mailcow_integration/migrations/15.0.1.0.1/pre-migrate.py new file mode 100644 index 0000000..451c1c0 --- /dev/null +++ b/bemade_mailcow_integration/migrations/15.0.1.0.1/pre-migrate.py @@ -0,0 +1,13 @@ +from odoo import api, SUPERUSER_ID + + +def migrate(cr, version): + env = api.Environment(cr, SUPERUSER_ID, {}) + settings = env['ir.config_parameter'] + create_param = settings.get_param('mailcow.create_mailbox') + sync_param = settings.get_param('mailcow.sync_alias') + base_url = settings.get_param('mailcow.base_url') + api_key = settings.get_param('mailcow.api_key') + + if (create_param or sync_param) and (not base_url or not api_key): + (create_param | sync_param).write({'value': False}) diff --git a/bemade_mailcow_integration/models/mail_alias.py b/bemade_mailcow_integration/models/mail_alias.py index 2a69a78..62c466e 100644 --- a/bemade_mailcow_integration/models/mail_alias.py +++ b/bemade_mailcow_integration/models/mail_alias.py @@ -8,8 +8,12 @@ class MailAlias(models.Model): @api.model def create(self, vals): + params = self.env['ir.config_parameter'].sudo() + param_auto_create = params.get_param('mailcow.create_mailbox') + alias = super(MailAlias, self).create(vals) - if not alias.alias_name: + + if not alias.alias_name or not param_auto_create: return alias alias_domain = self.env["ir.config_parameter"].sudo().get_param("mail.catchall.domain"), diff --git a/bemade_mailcow_integration/models/res_config_settings.py b/bemade_mailcow_integration/models/res_config_settings.py index e0b47e5..bd5db68 100644 --- a/bemade_mailcow_integration/models/res_config_settings.py +++ b/bemade_mailcow_integration/models/res_config_settings.py @@ -1,4 +1,6 @@ -from odoo import fields, models +from odoo import fields, models, api, _ +from odoo.exceptions import ValidationError + class ResConfigSettings(models.TransientModel): _inherit = 'res.config.settings' @@ -23,3 +25,8 @@ class ResConfigSettings(models.TransientModel): string='Create Mailboxes in Mailcow', help='Auto create Mailboxes in Mailcow on creation in Odoo', config_parameter='mailcow.create_mailbox') + + @api.constrains('mailcow_sync_alias', 'mailcow_auto_create') + def require_api_key_and_base_url_to_sync(self): + if not self.mailcow_api_key and self.mailcow_base_url: + raise ValidationError(_("You must set a base URL and API key to enable synchronization.")) From 917fc8c01ea65ddd1f284a0de965e0ecbfa26d12 Mon Sep 17 00:00:00 2001 From: Marc Durepos Date: Tue, 12 Mar 2024 14:16:40 -0400 Subject: [PATCH 4/9] [ADD] bemade_utils: new module currently only with a decorator for patching tests. --- bemade_utils/__init__.py | 0 bemade_utils/__manifest__.py | 33 ++++++++++++++++++++++++ bemade_utils/tests/__init__.py | 1 + bemade_utils/tests/test_patching_test.py | 17 ++++++++++++ bemade_utils/tools/test.py | 28 ++++++++++++++++++++ 5 files changed, 79 insertions(+) create mode 100644 bemade_utils/__init__.py create mode 100644 bemade_utils/__manifest__.py create mode 100644 bemade_utils/tests/__init__.py create mode 100644 bemade_utils/tests/test_patching_test.py create mode 100644 bemade_utils/tools/test.py diff --git a/bemade_utils/__init__.py b/bemade_utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bemade_utils/__manifest__.py b/bemade_utils/__manifest__.py new file mode 100644 index 0000000..e330099 --- /dev/null +++ b/bemade_utils/__manifest__.py @@ -0,0 +1,33 @@ +# +# Bemade Inc. +# +# Copyright (C) 2023-June Bemade Inc. (). +# Author: Marc Durepos (Contact : marc@bemade.org) +# +# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) +# It is forbidden to publish, distribute, sublicense, or sell copies of the Software +# or modified copies of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +{ + 'name': 'Bemade App Utilities', + 'version': '15.0.1.0.0', + 'summary': 'Utilities commonly used in Bemade modules.', + 'description': 'Adds utilities such as an annotation for patching tests when modifying Odoo behaviour.', + 'category': 'Technical', + 'author': 'Bemade Inc.', + 'website': 'http://www.bemade.org', + 'license': 'OPL-1', + 'depends': [], + 'data': [], + 'assets': {}, + 'installable': True, + 'auto_install': False +} diff --git a/bemade_utils/tests/__init__.py b/bemade_utils/tests/__init__.py new file mode 100644 index 0000000..27cd6d5 --- /dev/null +++ b/bemade_utils/tests/__init__.py @@ -0,0 +1 @@ +from . import test_patching_test diff --git a/bemade_utils/tests/test_patching_test.py b/bemade_utils/tests/test_patching_test.py new file mode 100644 index 0000000..9b4b5da --- /dev/null +++ b/bemade_utils/tests/test_patching_test.py @@ -0,0 +1,17 @@ +from odoo.tests import TransactionCase +from addons.bemade_utils.tools.test import patch_test + + +class TestA(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + def test_method_a(self): + self.assertFalse(True) + + +class TestB(TransactionCase): + @patch_test(TestA.test_method_a) + def test_redefining_test(self): + self.assertTrue(True) diff --git a/bemade_utils/tools/test.py b/bemade_utils/tools/test.py new file mode 100644 index 0000000..29e34d3 --- /dev/null +++ b/bemade_utils/tools/test.py @@ -0,0 +1,28 @@ +import importlib +from functools import wraps + + +def patch_test(original_method): + """ + A decorator that patches an Odoo test method with a new one. + The original_method is a direct reference to the method to be patched. + """ + def decorator(new_method): + @wraps(new_method) + def wrapper(*args, **kwargs): + return new_method(*args, **kwargs) + + # Extract module and class names + module_name = original_method.__module__ + class_name = original_method.__qualname__.split('.')[0] # Assuming the method is always in a class + + # Import the module + module = importlib.import_module(module_name) + # Get the class + cls = getattr(module, class_name) + + # Replace the original method with the new one + setattr(cls, original_method.__name__, wrapper) + + return wrapper + return decorator From 1a5f216b1d4d34b51d7074c5fb84225838ca4292 Mon Sep 17 00:00:00 2001 From: Marc Durepos Date: Tue, 12 Mar 2024 14:28:14 -0400 Subject: [PATCH 5/9] Slight improvement on test case for bemade_utils. --- bemade_utils/tests/test_patching_test.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bemade_utils/tests/test_patching_test.py b/bemade_utils/tests/test_patching_test.py index 9b4b5da..cc39b41 100644 --- a/bemade_utils/tests/test_patching_test.py +++ b/bemade_utils/tests/test_patching_test.py @@ -11,7 +11,6 @@ class TestA(TransactionCase): self.assertFalse(True) -class TestB(TransactionCase): - @patch_test(TestA.test_method_a) - def test_redefining_test(self): - self.assertTrue(True) +@patch_test(TestA.test_method_a) +def test_redefining_test(self): + self.assertTrue(True) From 0191aeba51a2a8f12dbbb100a50b0368b01d1898 Mon Sep 17 00:00:00 2001 From: Marc Durepos Date: Tue, 12 Mar 2024 16:44:18 -0400 Subject: [PATCH 6/9] bemade_utils update --- bemade_utils/tools/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bemade_utils/tools/test.py b/bemade_utils/tools/test.py index 29e34d3..3f4aa18 100644 --- a/bemade_utils/tools/test.py +++ b/bemade_utils/tools/test.py @@ -14,7 +14,7 @@ def patch_test(original_method): # Extract module and class names module_name = original_method.__module__ - class_name = original_method.__qualname__.split('.')[0] # Assuming the method is always in a class + class_name = original_method.__qualname__.split('.')[0] # Import the module module = importlib.import_module(module_name) From d0fc6363c457b9cf79bd76e528b679f88a166369 Mon Sep 17 00:00:00 2001 From: Marc Durepos Date: Wed, 13 Mar 2024 19:19:28 -0400 Subject: [PATCH 7/9] [IMP] bemade_utils: easier access to util function. --- bemade_utils/__init__.py | 1 + bemade_utils/tests/test_patching_test.py | 2 +- bemade_utils/tools/__init__.py | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 bemade_utils/tools/__init__.py diff --git a/bemade_utils/__init__.py b/bemade_utils/__init__.py index e69de29..9ac735b 100644 --- a/bemade_utils/__init__.py +++ b/bemade_utils/__init__.py @@ -0,0 +1 @@ +from odoo.addons.bemade_utils.tools import patch_test diff --git a/bemade_utils/tests/test_patching_test.py b/bemade_utils/tests/test_patching_test.py index cc39b41..9cd5bb4 100644 --- a/bemade_utils/tests/test_patching_test.py +++ b/bemade_utils/tests/test_patching_test.py @@ -1,5 +1,5 @@ from odoo.tests import TransactionCase -from addons.bemade_utils.tools.test import patch_test +from addons.bemade_utils import patch_test class TestA(TransactionCase): diff --git a/bemade_utils/tools/__init__.py b/bemade_utils/tools/__init__.py new file mode 100644 index 0000000..f467f1c --- /dev/null +++ b/bemade_utils/tools/__init__.py @@ -0,0 +1,2 @@ +from .test import patch_test + From c98e9498281844bee8f78e8bd184ce491bfa7596 Mon Sep 17 00:00:00 2001 From: Marc Durepos Date: Mon, 18 Mar 2024 13:50:58 -0400 Subject: [PATCH 8/9] bemade_fix_quality_report to fix quality reports not printing on Odoo Enterprise --- bemade_fix_quality_report/__init__.py | 0 bemade_fix_quality_report/__manifest__.py | 33 +++++++++++++++++++ .../worksheet_custom_report_templates.xml | 8 +++++ .../__manifest__.py | 7 ++-- .../views/sale_order_views.xml | 20 +++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 bemade_fix_quality_report/__init__.py create mode 100644 bemade_fix_quality_report/__manifest__.py create mode 100644 bemade_fix_quality_report/reports/worksheet_custom_report_templates.xml create mode 100644 bemade_multiple_billing_contacts/views/sale_order_views.xml diff --git a/bemade_fix_quality_report/__init__.py b/bemade_fix_quality_report/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bemade_fix_quality_report/__manifest__.py b/bemade_fix_quality_report/__manifest__.py new file mode 100644 index 0000000..3fcec26 --- /dev/null +++ b/bemade_fix_quality_report/__manifest__.py @@ -0,0 +1,33 @@ +# +# Bemade Inc. +# +# Copyright (C) 2023-June Bemade Inc. (). +# Author: Marc Durepos (Contact : marc@bemade.org) +# +# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) +# It is forbidden to publish, distribute, sublicense, or sell copies of the Software +# or modified copies of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +{ + 'name': 'Fix Quality Worksheet', + 'version': '15.0.1.0.0', + 'summary': 'Fix Quality worksheet bug from Odoo Enterprise', + 'description': '', + 'category': 'Quality Control', + 'author': 'Bemade Inc.', + 'website': 'http://www.bemade.org', + 'license': 'OPL-1', + 'depends': ['quality_control'], + 'data': ['reports/worksheet_custom_report_templates.xml'], + 'assets': {}, + 'installable': True, + 'auto_install': True, +} diff --git a/bemade_fix_quality_report/reports/worksheet_custom_report_templates.xml b/bemade_fix_quality_report/reports/worksheet_custom_report_templates.xml new file mode 100644 index 0000000..2126fd3 --- /dev/null +++ b/bemade_fix_quality_report/reports/worksheet_custom_report_templates.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/bemade_multiple_billing_contacts/__manifest__.py b/bemade_multiple_billing_contacts/__manifest__.py index 8dd875e..43fb1be 100644 --- a/bemade_multiple_billing_contacts/__manifest__.py +++ b/bemade_multiple_billing_contacts/__manifest__.py @@ -31,8 +31,11 @@ 'account', 'bemade_partner_root_ancestor', ], - 'data': ['views/account_move_views.xml', - 'views/res_partner_views.xml'], + 'data': [ + 'views/account_move_views.xml', + 'views/res_partner_views.xml', + 'views/sale_order_views.xml', + ], 'demo': [], 'installable': True, 'auto_install': False, diff --git a/bemade_multiple_billing_contacts/views/sale_order_views.xml b/bemade_multiple_billing_contacts/views/sale_order_views.xml new file mode 100644 index 0000000..35fe9f3 --- /dev/null +++ b/bemade_multiple_billing_contacts/views/sale_order_views.xml @@ -0,0 +1,20 @@ + + + + view_sale_order_form_inherit + sale.order + + + + + + + + + + \ No newline at end of file From 4972b04951d51346aede8de55115e37bd21d7b6c Mon Sep 17 00:00:00 2001 From: Marc Durepos Date: Mon, 18 Mar 2024 13:55:12 -0400 Subject: [PATCH 9/9] bemade_fix_quality_report stuff --- .../reports/worksheet_custom_report_templates.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bemade_fix_quality_report/reports/worksheet_custom_report_templates.xml b/bemade_fix_quality_report/reports/worksheet_custom_report_templates.xml index 2126fd3..b624e98 100644 --- a/bemade_fix_quality_report/reports/worksheet_custom_report_templates.xml +++ b/bemade_fix_quality_report/reports/worksheet_custom_report_templates.xml @@ -1,6 +1,6 @@ -