@ -0,0 +1,49 @@ | 
				
			|||
.. 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 Wise Shipping Method | 
				
			|||
============================ | 
				
			|||
This module allow users to manage product wise shipping methods. | 
				
			|||
 | 
				
			|||
Configuration | 
				
			|||
============= | 
				
			|||
* Enable "Pricelists" Sale Order Configuration Settings. | 
				
			|||
 | 
				
			|||
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 | 
				
			|||
------- | 
				
			|||
* Developers: (V16) Farhana Jahan PT, | 
				
			|||
              (V17) Sabeel B, | 
				
			|||
              (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) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) | 
				
			|||
#    Author: Cybrosys Techno Solutions (odoo@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,43 @@ | 
				
			|||
# -*- coding: utf-8 -*- | 
				
			|||
############################################################################# | 
				
			|||
# | 
				
			|||
#    Cybrosys Technologies Pvt. Ltd. | 
				
			|||
# | 
				
			|||
#    Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) | 
				
			|||
#    Author: Cybrosys Techno Solutions (odoo@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 Wise Shipping Method', | 
				
			|||
    'version': '18.0.1.0.0', | 
				
			|||
    'category': 'Sales', | 
				
			|||
    'summary': """Product Wise Shipping Method for sale order.""", | 
				
			|||
    'description': """This module helps to provide shipping methods easily via | 
				
			|||
    choosing products in sale order line.""", | 
				
			|||
    'author': 'Cybrosys Techno Solutions', | 
				
			|||
    'company': 'Cybrosys Techno Solutions', | 
				
			|||
    'maintainer': 'Cybrosys Techno Solutions', | 
				
			|||
    'website': 'https://www.cybrosys.com', | 
				
			|||
    'depends': ['sale_management', 'delivery', 'website_sale'], | 
				
			|||
    'data': [ | 
				
			|||
        'views/product_template_views.xml', | 
				
			|||
        'views/sale_order_views.xml', | 
				
			|||
    ], | 
				
			|||
    'images': ['static/description/banner.jpg'], | 
				
			|||
    'license': 'AGPL-3', | 
				
			|||
    'installable': True, | 
				
			|||
    'auto_install': False, | 
				
			|||
    'application': False, | 
				
			|||
} | 
				
			|||
@ -0,0 +1,6 @@ | 
				
			|||
## Module <product_wise_shipping_method> | 
				
			|||
 | 
				
			|||
#### 12.02.2025 | 
				
			|||
#### Version 18.0.1.0.0 | 
				
			|||
##### ADD | 
				
			|||
- Initial commit for Product Wise Shipping Method | 
				
			|||
@ -0,0 +1,23 @@ | 
				
			|||
# -*- coding: utf-8 -*- | 
				
			|||
############################################################################# | 
				
			|||
# | 
				
			|||
#    Cybrosys Technologies Pvt. Ltd. | 
				
			|||
# | 
				
			|||
#    Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) | 
				
			|||
#    Author: Cybrosys Techno Solutions (odoo@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_template | 
				
			|||
from . import sale_order | 
				
			|||
@ -0,0 +1,32 @@ | 
				
			|||
# -*- coding: utf-8 -*- | 
				
			|||
############################################################################# | 
				
			|||
# | 
				
			|||
#    Cybrosys Technologies Pvt. Ltd. | 
				
			|||
# | 
				
			|||
#    Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | 
				
			|||
#    Author: Cybrosys Techno Solutions (odoo@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 fields, models | 
				
			|||
 | 
				
			|||
 | 
				
			|||
class ProductTemplate(models.Model): | 
				
			|||
    """ Inheriting product.template model for adding a field for defining | 
				
			|||
    shipping method. """ | 
				
			|||
    _inherit = 'product.template' | 
				
			|||
 | 
				
			|||
    shipping_method_id = fields.Many2one('delivery.carrier', | 
				
			|||
                                         string='Shipping Method', | 
				
			|||
                                         help="Choose shipping method.") | 
				
			|||
@ -0,0 +1,114 @@ | 
				
			|||
# -*- coding: utf-8 -*- | 
				
			|||
############################################################################# | 
				
			|||
# | 
				
			|||
#    Cybrosys Technologies Pvt. Ltd. | 
				
			|||
# | 
				
			|||
#    Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). | 
				
			|||
#    Author: Cybrosys Techno Solutions(odoo@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 collections import defaultdict | 
				
			|||
from odoo import api, models, _ | 
				
			|||
from odoo.exceptions import UserError | 
				
			|||
 | 
				
			|||
 | 
				
			|||
class SaleOrder(models.Model): | 
				
			|||
    """ Inheriting sale.order, so we are getting shipping method corresponding to | 
				
			|||
    product. """ | 
				
			|||
    _inherit = 'sale.order' | 
				
			|||
 | 
				
			|||
    def action_confirm(self): | 
				
			|||
        """ Create delivery method value for sale order lines with a | 
				
			|||
         shipping method. """ | 
				
			|||
        if self.website_id: | 
				
			|||
            return super().action_confirm() | 
				
			|||
        order_lines_with_shipping = (self.order_line.filtered | 
				
			|||
                                     (lambda line: line.product_template_id. | 
				
			|||
                                      shipping_method_id)) | 
				
			|||
        vals_list = [{ | 
				
			|||
            'product_id': line.product_template_id.shipping_method_id. | 
				
			|||
            product_id.id, | 
				
			|||
            'name': line.product_template_id.shipping_method_id.name, | 
				
			|||
            'product_uom': line.product_template_id.shipping_method_id. | 
				
			|||
            product_id.uom_id.id, | 
				
			|||
            'price_unit': line.product_template_id.shipping_method_id. | 
				
			|||
            product_id.list_price, | 
				
			|||
            'order_id': self.id, | 
				
			|||
        } for line in order_lines_with_shipping] | 
				
			|||
        self.env['sale.order.line'].create(vals_list) | 
				
			|||
        self.merge_similar_products() | 
				
			|||
        return super().action_confirm() | 
				
			|||
 | 
				
			|||
    def merge_similar_products(self): | 
				
			|||
        """ Merge similar products on order line by adding their quantity. """ | 
				
			|||
        similar_products = defaultdict( | 
				
			|||
            lambda: {'qty': 0, 'lines_to_remove': []}) | 
				
			|||
        order_line = self.env['sale.order.line'] | 
				
			|||
        for line in self.order_line.sorted(): | 
				
			|||
            key = (line.product_id.id, line.price_unit, line.tax_id) | 
				
			|||
            similar_products[key]['qty'] += line.product_uom_qty | 
				
			|||
            similar_products[key]['lines_to_remove'].append(line.id) | 
				
			|||
        for key, product_info in similar_products.items(): | 
				
			|||
            order_line.browse(product_info['lines_to_remove'][0]).write( | 
				
			|||
                {'product_uom_qty': product_info['qty']}) | 
				
			|||
            order_line.browse(product_info['lines_to_remove'][1:]).unlink() | 
				
			|||
 | 
				
			|||
    @api.model | 
				
			|||
    def create(self, vals): | 
				
			|||
        """ When the products are newly selected in sale order line then they | 
				
			|||
        are Create on sale order """ | 
				
			|||
        res = super().create(vals) | 
				
			|||
        res.merge_similar_products() | 
				
			|||
        return res | 
				
			|||
 | 
				
			|||
    def write(self, vals): | 
				
			|||
        """ When the products are previously selected then Write similar | 
				
			|||
         products on sale order """ | 
				
			|||
        res = super().write(vals) | 
				
			|||
        self.merge_similar_products() | 
				
			|||
        return res | 
				
			|||
 | 
				
			|||
    def action_open_delivery_wizard(self): | 
				
			|||
        """ Restrict adding a shipping method or open the delivery carrier | 
				
			|||
        selection form. | 
				
			|||
        if product have shipping method then get error message | 
				
			|||
        if product hasn't shipping method then can open wizard. """ | 
				
			|||
        if any(line.product_template_id.shipping_method_id for line in | 
				
			|||
               self.order_line): | 
				
			|||
            raise UserError('Shipping method is already applied...!!') | 
				
			|||
        else: | 
				
			|||
            view_id = (self.env.ref | 
				
			|||
                       ('delivery.choose_delivery_carrier_view_form').id) | 
				
			|||
            name = _('Add a shipping method') | 
				
			|||
            carrier = ( | 
				
			|||
                    self.with_company(self.company_id).partner_shipping_id. | 
				
			|||
                    property_delivery_carrier_id | 
				
			|||
                    or self.with_company(self.company_id).partner_shipping_id. | 
				
			|||
                    commercial_partner_id. | 
				
			|||
                    property_delivery_carrier_id | 
				
			|||
            ) | 
				
			|||
            return { | 
				
			|||
                'name': name, | 
				
			|||
                'type': 'ir.actions.act_window', | 
				
			|||
                'view_mode': 'form', | 
				
			|||
                'res_model': 'choose.delivery.carrier', | 
				
			|||
                'view_id': view_id, | 
				
			|||
                'views': [(view_id, 'form')], | 
				
			|||
                'target': 'new', | 
				
			|||
                'context': { | 
				
			|||
                    'default_order_id': self.id, | 
				
			|||
                    'default_carrier_id': carrier.id, | 
				
			|||
                } | 
				
			|||
            } | 
				
			|||
| 
		 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: 92 KiB  | 
| 
		 After Width: | Height: | Size: 131 KiB  | 
| 
		 After Width: | Height: | Size: 88 KiB  | 
| 
		 After Width: | Height: | Size: 87 KiB  | 
| 
		 After Width: | Height: | Size: 92 KiB  | 
| 
		 After Width: | Height: | Size: 87 KiB  | 
| 
		 After Width: | Height: | Size: 95 KiB  | 
| 
		 After Width: | Height: | Size: 81 KiB  | 
| 
		 After Width: | Height: | Size: 88 KiB  | 
| 
		 After Width: | Height: | Size: 124 KiB  | 
| 
		 After Width: | Height: | Size: 159 KiB  | 
| 
		 After Width: | Height: | Size: 880 KiB  | 
| 
		 After Width: | Height: | Size: 142 KiB  | 
| 
		 After Width: | Height: | Size: 11 KiB  | 
@ -0,0 +1,19 @@ | 
				
			|||
<?xml version="1.0" encoding="utf-8" ?> | 
				
			|||
<odoo> | 
				
			|||
    <record id="product_template_only_form_view" model="ir.ui.view"> | 
				
			|||
        <!--Inherit product template form view--> | 
				
			|||
        <field name="name"> | 
				
			|||
            product.template.view.form.inherit.product.wise.shipping.method | 
				
			|||
        </field> | 
				
			|||
        <field name="model">product.template</field> | 
				
			|||
        <field name="inherit_id" | 
				
			|||
               ref="product.product_template_only_form_view"/> | 
				
			|||
        <field name="arch" type="xml"> | 
				
			|||
            <!--Add shipping method field to inherited form and defining its | 
				
			|||
            position--> | 
				
			|||
            <field name="categ_id" position="after"> | 
				
			|||
                <field name="shipping_method_id"/> | 
				
			|||
            </field> | 
				
			|||
        </field> | 
				
			|||
    </record> | 
				
			|||
</odoo> | 
				
			|||
@ -0,0 +1,18 @@ | 
				
			|||
<?xml version="1.0" encoding="UTF-8" ?> | 
				
			|||
<odoo> | 
				
			|||
    <record id="view_order_form" model="ir.ui.view"> | 
				
			|||
        <!--Inherit sale order form view--> | 
				
			|||
        <field name="name"> | 
				
			|||
            sale.order.view.form.inherit.product.wise.shipping.method | 
				
			|||
        </field> | 
				
			|||
        <field name="model">sale.order</field> | 
				
			|||
        <field name="inherit_id" ref="sale.view_order_form"/> | 
				
			|||
        <field name="arch" type="xml"> | 
				
			|||
            <!--Hide add delivery button from draft stage--> | 
				
			|||
            <xpath expr="//button[@name='action_open_delivery_wizard']" | 
				
			|||
                   position="attributes"> | 
				
			|||
                <attribute name="invisible">state == 'draft'</attribute> | 
				
			|||
            </xpath> | 
				
			|||
        </field> | 
				
			|||
    </record> | 
				
			|||
</odoo> | 
				
			|||