| @ -0,0 +1,47 @@ | |||||
|  | .. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg | ||||
|  |     :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html | ||||
|  |     :alt: License: AGPL-3 | ||||
|  | 
 | ||||
|  | Product Multi UoM | ||||
|  | ================= | ||||
|  | This module help to sell a product with multiple Uom category. | ||||
|  | 
 | ||||
|  | Configuration | ||||
|  | ============= | ||||
|  | * No additional configurations needed | ||||
|  | 
 | ||||
|  | Company | ||||
|  | ------- | ||||
|  | * `Cybrosys Techno Solutions <https://cybrosys.com/>`__ | ||||
|  | 
 | ||||
|  | License | ||||
|  | ------- | ||||
|  | Affero General Public License v3.0 (AGPL v3) | ||||
|  | (https://www.gnu.org/licenses/agpl-3.0-standalone.html) | ||||
|  | 
 | ||||
|  | Credits | ||||
|  | ------- | ||||
|  | Developer: (v18) Ammu Raj, | ||||
|  | Contact: odoo@cybrosys.com | ||||
|  | 
 | ||||
|  | Contacts | ||||
|  | -------- | ||||
|  | * Mail Contact : odoo@cybrosys.com | ||||
|  | * Website : https://cybrosys.com | ||||
|  | 
 | ||||
|  | Bug Tracker | ||||
|  | ----------- | ||||
|  | Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. | ||||
|  | 
 | ||||
|  | Maintainer | ||||
|  | ========== | ||||
|  | .. image:: https://cybrosys.com/images/logo.png | ||||
|  |    :target: https://cybrosys.com | ||||
|  | 
 | ||||
|  | This module is maintained by Cybrosys Technologies. | ||||
|  | 
 | ||||
|  | For support and more information, please visit `Our Website <https://cybrosys.com/>`__ | ||||
|  | 
 | ||||
|  | Further information | ||||
|  | =================== | ||||
|  | HTML Description: `<static/description/index.html>`__ | ||||
| @ -0,0 +1,22 @@ | |||||
|  | # -*- coding: utf-8 -*- | ||||
|  | ############################################################################# | ||||
|  | # | ||||
|  | #    Cybrosys Technologies Pvt. Ltd. | ||||
|  | # | ||||
|  | #    Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) | ||||
|  | #    Author: Ammu Raj (<https://www.cybrosys.com>) | ||||
|  | # | ||||
|  | #    You can modify it under the terms of the GNU AFFERO | ||||
|  | #    GENERAL PUBLIC LICENSE (AGPL v3), Version 3. | ||||
|  | # | ||||
|  | #    This program is distributed in the hope that it will be useful, | ||||
|  | #    but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  | #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  | #    GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. | ||||
|  | # | ||||
|  | #    You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE | ||||
|  | #    (AGPL v3) along with this program. | ||||
|  | #    If not, see <http://www.gnu.org/licenses/>. | ||||
|  | # | ||||
|  | ############################################################################# | ||||
|  | from . import models | ||||
| @ -0,0 +1,48 @@ | |||||
|  | # -*- coding: utf-8 -*- | ||||
|  | ############################################################################# | ||||
|  | # | ||||
|  | #    Cybrosys Technologies Pvt. Ltd. | ||||
|  | # | ||||
|  | #    Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) | ||||
|  | #    Author: Ammu Raj (<https://www.cybrosys.com>) | ||||
|  | # | ||||
|  | #    You can modify it under the terms of the GNU AFFERO | ||||
|  | #    GENERAL PUBLIC LICENSE (AGPL v3), Version 3. | ||||
|  | # | ||||
|  | #    This program is distributed in the hope that it will be useful, | ||||
|  | #    but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  | #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  | #    GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. | ||||
|  | # | ||||
|  | #    You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE | ||||
|  | #    (AGPL v3) along with this program. | ||||
|  | #    If not, see <http://www.gnu.org/licenses/>. | ||||
|  | # | ||||
|  | ############################################################################# | ||||
|  | { | ||||
|  |     'name': "Product Multi UoM", | ||||
|  |     'version': '18.0.1.0.0', | ||||
|  |     'category': 'Sales', | ||||
|  |     'summary': 'This module help to sell a product with multiple Uom category', | ||||
|  |     'description': "This versatile module empowers your sales strategy by " | ||||
|  |                    "seamlessly handling products with diverse unit of measure " | ||||
|  |                    "categories. Whether you're selling by length, weight, " | ||||
|  |                    "quantity, or more, this module ensures a streamlined and" | ||||
|  |                    "efficient process, allowing you to offer and sell your " | ||||
|  |                    "products with different UOM categories effortlessly.", | ||||
|  |     'author': 'Cybrosys Techno Solutions', | ||||
|  |     'company': 'Cybrosys Techno Solutions', | ||||
|  |     'maintainer': 'Cybrosys Techno Solutions', | ||||
|  |     'website': 'https://www.cybrosys.com', | ||||
|  |     'depends': ['sale_management'], | ||||
|  |     'data': [ | ||||
|  |         'security/ir.model.access.csv', | ||||
|  |         'views/product_product_views.xml', | ||||
|  |         'views/sale_order_line_views.xml', | ||||
|  |     ], | ||||
|  |     'images': ['static/description/banner.png'], | ||||
|  |     'license': 'AGPL-3', | ||||
|  |     'installable': True, | ||||
|  |     'auto_install': False, | ||||
|  |     'application': False, | ||||
|  | } | ||||
| @ -0,0 +1,6 @@ | |||||
|  | ## Module <product_multi_uom> | ||||
|  | 
 | ||||
|  | #### 11.11.2024 | ||||
|  | #### Version 18.0.1.0.0 | ||||
|  | ##### ADD | ||||
|  | - Initial Commit for Product Multi UoM | ||||
| @ -0,0 +1,24 @@ | |||||
|  | # -*- coding: utf-8 -*- | ||||
|  | ############################################################################# | ||||
|  | # | ||||
|  | #    Cybrosys Technologies Pvt. Ltd. | ||||
|  | # | ||||
|  | #    Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) | ||||
|  | #    Author: Ammu Raj (<https://www.cybrosys.com>) | ||||
|  | # | ||||
|  | #    You can modify it under the terms of the GNU AFFERO | ||||
|  | #    GENERAL PUBLIC LICENSE (AGPL v3), Version 3. | ||||
|  | # | ||||
|  | #    This program is distributed in the hope that it will be useful, | ||||
|  | #    but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  | #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  | #    GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. | ||||
|  | # | ||||
|  | #    You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE | ||||
|  | #    (AGPL v3) along with this program. | ||||
|  | #    If not, see <http://www.gnu.org/licenses/>. | ||||
|  | # | ||||
|  | ############################################################################# | ||||
|  | from . import product_product | ||||
|  | from . import sale_order_line | ||||
|  | from . import secondary_uom_line | ||||
| @ -0,0 +1,52 @@ | |||||
|  | # -*- coding: utf-8 -*- | ||||
|  | ############################################################################# | ||||
|  | # | ||||
|  | #    Cybrosys Technologies Pvt. Ltd. | ||||
|  | # | ||||
|  | #    Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) | ||||
|  | #    Author: Ammu Raj (<https://www.cybrosys.com>) | ||||
|  | # | ||||
|  | #    You can modify it under the terms of the GNU AFFERO | ||||
|  | #    GENERAL PUBLIC LICENSE (AGPL v3), Version 3. | ||||
|  | # | ||||
|  | #    This program is distributed in the hope that it will be useful, | ||||
|  | #    but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  | #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  | #    GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. | ||||
|  | # | ||||
|  | #    You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE | ||||
|  | #    (AGPL v3) along with this program. | ||||
|  | #    If not, see <http://www.gnu.org/licenses/>. | ||||
|  | # | ||||
|  | ############################################################################# | ||||
|  | from odoo import api, fields, models | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | class ProductProduct(models.Model): | ||||
|  |     """Inherits the 'product.template' for adding the secondary uom""" | ||||
|  |     _inherit = "product.product" | ||||
|  | 
 | ||||
|  |     is_need_secondary_uom = fields.Boolean(string="Need Secondary UoM's", | ||||
|  |                                            help="Enable this field for " | ||||
|  |                                                 "using the secondary uom") | ||||
|  |     secondary_uom_ids = fields.One2many('secondary.uom.line', 'product_id', | ||||
|  |                                         string="Secondary UoM's", | ||||
|  |                                         help='Select the secondary UoM and ' | ||||
|  |                                              'their ratio', store=True) | ||||
|  | 
 | ||||
|  |     @api.onchange('is_need_secondary_uom') | ||||
|  |     def _onchange_is_need_secondary_uom(self): | ||||
|  |         """Function that write the default Uom and their ratio to the | ||||
|  |         secondary uom""" | ||||
|  |         base_uom = self.env['uom.uom'].sudo().search( | ||||
|  |                 [('category_id', '=', self.uom_id.category_id.id)]) | ||||
|  |         if not self.secondary_uom_ids: | ||||
|  |             for uom in base_uom: | ||||
|  |                 self.write({ | ||||
|  |                     'secondary_uom_ids': [(0, 0, { | ||||
|  |                         'secondary_uom_id': uom.id, | ||||
|  |                         'secondary_uom_ratio': float(uom.factor_inv), | ||||
|  |                         'example_ratio': f" 1 {uom.name} = {uom.factor_inv}" | ||||
|  |                                          f" {self.uom_id.name}", | ||||
|  |                     })] | ||||
|  |                 }) | ||||
| @ -0,0 +1,80 @@ | |||||
|  | # -*- coding: utf-8 -*- | ||||
|  | ############################################################################# | ||||
|  | # | ||||
|  | #    Cybrosys Technologies Pvt. Ltd. | ||||
|  | # | ||||
|  | #    Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) | ||||
|  | #    Author: Ammu Raj (<https://www.cybrosys.com>) | ||||
|  | # | ||||
|  | #    You can modify it under the terms of the GNU AFFERO | ||||
|  | #    GENERAL PUBLIC LICENSE (AGPL v3), Version 3. | ||||
|  | # | ||||
|  | #    This program is distributed in the hope that it will be useful, | ||||
|  | #    but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  | #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  | #    GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. | ||||
|  | # | ||||
|  | #    You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE | ||||
|  | #    (AGPL v3) along with this program. | ||||
|  | #    If not, see <http://www.gnu.org/licenses/>. | ||||
|  | # | ||||
|  | ############################################################################# | ||||
|  | from odoo import api, fields, models | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | class SaleOrderLine(models.Model): | ||||
|  |     """Inherits the class sale.order.line for adding the fields for | ||||
|  |     secondary uom and the secondary uom Quantity""" | ||||
|  |     _inherit = 'sale.order.line' | ||||
|  | 
 | ||||
|  |     secondary_uom_ids = fields.Many2many('uom.uom', | ||||
|  |                                          string="Secondary Uom Ids", | ||||
|  |                                          help="For fetching all the secondary" | ||||
|  |                                               " uom's") | ||||
|  |     secondary_product_uom_id = fields.Many2one( | ||||
|  |         'uom.uom', string='Secondary UoM', | ||||
|  |         compute='_compute_secondary_product_uom', store=True, readonly=False, | ||||
|  |         help="Select the Secondary Uom", | ||||
|  |         domain="[('id', 'in', secondary_uom_ids)]") | ||||
|  |     secondary_product_uom_qty = fields.Float(string='Secondary Quantity', | ||||
|  |                                              help="Select the Secondary Uom " | ||||
|  |                                                   "Quantity", default=1) | ||||
|  |     is_secondary_readonly = fields.Boolean(string="Is Secondary Uom", | ||||
|  |                                            help="The field to check whether" | ||||
|  |                                                 " the selected uom is" | ||||
|  |                                                 " secondary and if yes then " | ||||
|  |                                                 "make the field readonly") | ||||
|  | 
 | ||||
|  |     @api.onchange('secondary_product_uom_id', 'secondary_product_uom_qty') | ||||
|  |     def _onchange_secondary_product_uom_id(self): | ||||
|  |         """Function that update the product_uom_qty as the value in the | ||||
|  |          secondary uom quantity""" | ||||
|  |         all_uom = [] | ||||
|  |         if self.product_id.is_need_secondary_uom: | ||||
|  |             self.is_secondary_readonly = True | ||||
|  |             for uom in self.product_id.secondary_uom_ids: | ||||
|  |                 all_uom.append(uom.secondary_uom_id.id) | ||||
|  |         if self.is_secondary_readonly: | ||||
|  |             self.product_uom_readonly = True | ||||
|  |             if self.secondary_product_uom_id.id in all_uom: | ||||
|  |                 primary_uom_ratio = self.env['secondary.uom.line'].search( | ||||
|  |                     [('secondary_uom_id', '=', self.secondary_product_uom_id.id), | ||||
|  |                      ('product_id', '=', self.product_id.id)]).mapped( | ||||
|  |                     'secondary_uom_ratio') | ||||
|  |                 converted_uom_qty = primary_uom_ratio[ | ||||
|  |                                         0] * self.secondary_product_uom_qty | ||||
|  |                 self.product_uom_qty = converted_uom_qty | ||||
|  | 
 | ||||
|  |     @api.depends('product_id') | ||||
|  |     def _compute_secondary_product_uom(self): | ||||
|  |         """Compute the default secondary uom""" | ||||
|  |         for rec in self: | ||||
|  |             if (not rec.product_uom or | ||||
|  |                     rec.product_id.uom_id.id != rec.secondary_product_uom_id.id): | ||||
|  |                 rec.secondary_product_uom_id = rec.product_id.uom_id | ||||
|  |             all_secondary_uoms = rec.product_id.secondary_uom_ids.mapped( | ||||
|  |                 'secondary_uom_id') | ||||
|  |             if rec.product_id.is_need_secondary_uom and all_secondary_uoms: | ||||
|  |                 rec.write({ | ||||
|  |                     'secondary_uom_ids': [(6, 0, all_secondary_uoms.ids)] | ||||
|  |                 }) | ||||
| @ -0,0 +1,63 @@ | |||||
|  | # -*- coding: utf-8 -*- | ||||
|  | ############################################################################# | ||||
|  | # | ||||
|  | #    Cybrosys Technologies Pvt. Ltd. | ||||
|  | # | ||||
|  | #    Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) | ||||
|  | #    Author: Ammu Raj (<https://www.cybrosys.com>) | ||||
|  | # | ||||
|  | #    You can modify it under the terms of the GNU AFFERO | ||||
|  | #    GENERAL PUBLIC LICENSE (AGPL v3), Version 3. | ||||
|  | # | ||||
|  | #    This program is distributed in the hope that it will be useful, | ||||
|  | #    but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  | #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  | #    GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. | ||||
|  | # | ||||
|  | #    You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE | ||||
|  | #    (AGPL v3) along with this program. | ||||
|  | #    If not, see <http://www.gnu.org/licenses/>. | ||||
|  | # | ||||
|  | ############################################################################# | ||||
|  | from odoo import api, fields, models, _ | ||||
|  | from odoo.exceptions import ValidationError | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | class SecondaryUomLine(models.Model): | ||||
|  |     """Model Class for Secondary Uom Line | ||||
|  |     This class represents the secondary unit of measure (UOM) line in the | ||||
|  |     system. | ||||
|  |     It is designed to store information related to secondary UOMs.""" | ||||
|  |     _name = "secondary.uom.line" | ||||
|  |     _description = "Secondary Uom Line" | ||||
|  | 
 | ||||
|  |     secondary_uom_id = fields.Many2one('uom.uom', string='Secondary UoM', | ||||
|  |                                        help="Select the Secondary UoM", | ||||
|  |                                        required=True) | ||||
|  |     product_id = fields.Many2one('product.product', readonly=True, | ||||
|  |                                  string="Product", | ||||
|  |                                  help="Product having the Secondary UOM") | ||||
|  |     secondary_uom_ratio = fields.Float(string='Secondary UoM Ratio', | ||||
|  |                                        help="Choose the ratio with the base" | ||||
|  |                                             " Unit of Measure.") | ||||
|  |     example_ratio = fields.Char(string='Ratio', readonly=True, | ||||
|  |                                 help="Ratio of base Uom and the secondary Uom", | ||||
|  |                                 store=True) | ||||
|  | 
 | ||||
|  |     @api.onchange('secondary_uom_id', 'secondary_uom_ratio') | ||||
|  |     def _onchange_secondary_uom_id(self): | ||||
|  |         """Function that write the ratio in to the example ratio field and | ||||
|  |          check whether the selected secondary uom is already included in the | ||||
|  |          uom list""" | ||||
|  |         if self.secondary_uom_id and self.secondary_uom_ratio: | ||||
|  |             self.example_ratio = (f" 1 {self.secondary_uom_id.name}  = " | ||||
|  |                                   f" {self.secondary_uom_ratio} " | ||||
|  |                                   f"{self.product_id.uom_id.name}") | ||||
|  |         if self._context.get('params'): | ||||
|  |             sec_uom_ids = self.env['product.template'].browse( | ||||
|  |                 self._context.get('params').get('id')).secondary_uom_ids.mapped( | ||||
|  |                 'secondary_uom_id.id') | ||||
|  |             if self.secondary_uom_id.id in sec_uom_ids: | ||||
|  |                 raise ValidationError( | ||||
|  |                     _('This Unit of Measure is already exist in the secondary' | ||||
|  |                       'uom list. Please select another uom for secondary uom')) | ||||
| 
 | 
| After Width: | Height: | Size: 2.2 KiB | 
| After Width: | Height: | Size: 28 KiB | 
| After Width: | Height: | Size: 628 KiB | 
| After Width: | Height: | Size: 1.1 KiB | 
| After Width: | Height: | Size: 210 KiB | 
| After Width: | Height: | Size: 209 KiB | 
| After Width: | Height: | Size: 109 KiB | 
| After Width: | Height: | Size: 495 B | 
| After Width: | Height: | Size: 1.0 KiB | 
| After Width: | Height: | Size: 624 B | 
| After Width: | Height: | Size: 136 KiB | 
| After Width: | Height: | Size: 214 KiB | 
| After Width: | Height: | Size: 36 KiB | 
| After Width: | Height: | Size: 3.6 KiB | 
| After Width: | Height: | Size: 310 B | 
| After Width: | Height: | Size: 929 B | 
| After Width: | Height: | Size: 1.3 KiB | 
| After Width: | Height: | Size: 3.3 KiB | 
| After Width: | Height: | Size: 1.4 KiB | 
| After Width: | Height: | Size: 17 KiB | 
| After Width: | Height: | Size: 542 B | 
| After Width: | Height: | Size: 576 B | 
| After Width: | Height: | Size: 733 B | 
| After Width: | Height: | Size: 4.3 KiB | 
| After Width: | Height: | Size: 1.2 KiB | 
| After Width: | Height: | Size: 4.0 KiB | 
| After Width: | Height: | Size: 1.7 KiB | 
| After Width: | Height: | Size: 738 KiB | 
| After Width: | Height: | Size: 2.2 KiB | 
| After Width: | Height: | Size: 911 B | 
| After Width: | Height: | Size: 1.1 KiB | 
| After Width: | Height: | Size: 1.2 KiB | 
| After Width: | Height: | Size: 1.2 KiB | 
| After Width: | Height: | Size: 600 B | 
| After Width: | Height: | Size: 673 B | 
| After Width: | Height: | Size: 2.0 KiB | 
| After Width: | Height: | Size: 462 B | 
| After Width: | Height: | Size: 2.1 KiB | 
| After Width: | Height: | Size: 926 B | 
| After Width: | Height: | Size: 9.0 KiB | 
| After Width: | Height: | Size: 23 KiB | 
| After Width: | Height: | Size: 7.0 KiB | 
| After Width: | Height: | Size: 878 B | 
| After Width: | Height: | Size: 1.2 KiB | 
| After Width: | Height: | Size: 653 B | 
| After Width: | Height: | Size: 800 B | 
| After Width: | Height: | Size: 905 B | 
| After Width: | Height: | Size: 189 KiB | 
| After Width: | Height: | Size: 4.3 KiB | 
| After Width: | Height: | Size: 839 B | 
| After Width: | Height: | Size: 1.7 KiB | 
| After Width: | Height: | Size: 5.9 KiB | 
| After Width: | Height: | Size: 1.6 KiB | 
| After Width: | Height: | Size: 34 KiB | 
| After Width: | Height: | Size: 26 KiB | 
| After Width: | Height: | Size: 3.8 KiB | 
| After Width: | Height: | Size: 23 KiB | 
| After Width: | Height: | Size: 1.9 KiB | 
| After Width: | Height: | Size: 2.3 KiB | 
| After Width: | Height: | Size: 427 B | 
| After Width: | Height: | Size: 627 B | 
| After Width: | Height: | Size: 1.1 KiB | 
| After Width: | Height: | Size: 1.2 KiB | 
| After Width: | Height: | Size: 988 B | 
| After Width: | Height: | Size: 3.7 KiB | 
| After Width: | Height: | Size: 5.0 KiB | 
| After Width: | Height: | Size: 875 B | 
| After Width: | Height: | Size: 1.2 KiB | 
| After Width: | Height: | Size: 767 KiB | 
| After Width: | Height: | Size: 138 KiB | 
| After Width: | Height: | Size: 760 KiB | 
| After Width: | Height: | Size: 92 KiB | 
| After Width: | Height: | Size: 697 KiB | 
| After Width: | Height: | Size: 1.1 MiB | 
| After Width: | Height: | Size: 90 KiB | 
| After Width: | Height: | Size: 86 KiB | 
| After Width: | Height: | Size: 89 KiB | 
| After Width: | Height: | Size: 39 KiB | 
| After Width: | Height: | Size: 36 KiB | 
| After Width: | Height: | Size: 91 KiB | 
| After Width: | Height: | Size: 91 KiB | 
| After Width: | Height: | Size: 255 KiB | 
| After Width: | Height: | Size: 880 KiB | 
| After Width: | Height: | Size: 87 KiB | 
| After Width: | Height: | Size: 12 KiB | 
| @ -0,0 +1,24 @@ | |||||
|  | <?xml version="1.0" encoding="UTF-8" ?> | ||||
|  | <odoo> | ||||
|  |     <!--Inherits the product variant view for adding the field for selecting the secondary Uom--> | ||||
|  |     <record id="product_normal_form_view" model="ir.ui.view"> | ||||
|  |         <field name="name">product.product.view.form.inherit.product.multi.uom | ||||
|  |         </field> | ||||
|  |         <field name="model">product.product</field> | ||||
|  |         <field name="inherit_id" ref="product.product_normal_form_view"/> | ||||
|  |         <field name="arch" type="xml"> | ||||
|  |             <xpath expr="//field[@name='uom_po_id']" position="after"> | ||||
|  |                 <field name="is_need_secondary_uom" groups="uom.group_uom"/> | ||||
|  |                 <field name="secondary_uom_ids" | ||||
|  |                        invisible="is_need_secondary_uom == False" | ||||
|  |                        groups="uom.group_uom" force_save="1"> | ||||
|  |                     <list name="Secondary"> | ||||
|  |                         <field name="secondary_uom_id"/> | ||||
|  |                         <field name="secondary_uom_ratio" column_invisible="1"/> | ||||
|  |                         <field name="example_ratio" force_save="1"/> | ||||
|  |                     </list> | ||||
|  |                 </field> | ||||
|  |             </xpath> | ||||
|  |         </field> | ||||
|  |     </record> | ||||
|  | </odoo> | ||||
| @ -0,0 +1,34 @@ | |||||
|  | <?xml version="1.0" encoding="UTF-8" ?> | ||||
|  | <odoo> | ||||
|  |     <!--    Inherits the sale order view for adding the field for secondary uom and its qty --> | ||||
|  |     <record id="view_order_form" model="ir.ui.view"> | ||||
|  |         <field name="name">sale.order.view.form.inherit.product.multi.uom | ||||
|  |         </field> | ||||
|  |         <field name="inherit_id" ref="sale.view_order_form"/> | ||||
|  |         <field name="model">sale.order</field> | ||||
|  |         <field name="arch" type="xml"> | ||||
|  |             <xpath expr="//field[@name='order_line']/list/field[@name='product_uom'][2]" | ||||
|  |                    position="after"> | ||||
|  |                 <field name="is_secondary_readonly" column_invisible="1"/> | ||||
|  |                 <field name="secondary_product_uom_qty" | ||||
|  |                        readonly="is_secondary_readonly == False"/> | ||||
|  |                 <field name="secondary_product_uom_id" | ||||
|  |                        readonly="is_secondary_readonly == False"/> | ||||
|  |                 <field name="secondary_uom_ids" widget="many2many_tags" | ||||
|  |                        column_invisible="1"/> | ||||
|  |             </xpath> | ||||
|  |             <xpath expr="//field[@name='order_line']/list/field[@name='product_uom']" | ||||
|  |                    position="attributes"> | ||||
|  |                 <attribute name="readonly">is_secondary_readonly == True | ||||
|  |                 </attribute> | ||||
|  |             </xpath> | ||||
|  |             <xpath expr="//field[@name='order_line']/list/field[@name='product_uom_qty']" | ||||
|  |                    position="attributes"> | ||||
|  |                 <attribute name="readonly">is_secondary_readonly == True | ||||
|  |                 </attribute> | ||||
|  |                 <attribute name="force_save">1</attribute> | ||||
|  |             </xpath> | ||||
|  |         </field> | ||||
|  |     </record> | ||||
|  | </odoo> | ||||
|  | 
 | ||||