@ -0,0 +1,48 @@ |
|||
.. 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 |
|||
|
|||
Multiple Delivery Addresses for Sale Order |
|||
========================================== |
|||
Multiple Delivery Addresses can be added to the same sale order |
|||
|
|||
Configuration |
|||
============= |
|||
* No additional configurations needed |
|||
|
|||
License |
|||
------- |
|||
Affero General Public License, Version 3 (AGPL v3). |
|||
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
|||
|
|||
Company |
|||
------- |
|||
* 'Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
|||
|
|||
Credits |
|||
------- |
|||
Developers: (V18) Anzil K A |
|||
(V17) Ayana KP, |
|||
(v16) Raveena V, |
|||
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 https://www.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: Anzil K A (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,44 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Anzil K A (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': 'Multiple Delivery Addresses for Sale Order', |
|||
'version': '18.0.1.0.0', |
|||
'category': 'Sales', |
|||
'summary': """Multiple Delivery Addresses for Sale Order """, |
|||
'description': """ If the customer have multiple addresses, the user can |
|||
choose delivery addresses for each order lines. Then separate pickings |
|||
and delivery will be created for each of the addresses. """, |
|||
'author': 'Cybrosys Techno Solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'maintainer': 'Cybrosys Techno Solutions', |
|||
'website': 'https://www.cybrosys.com', |
|||
'depends': ['sale_management', 'stock'], |
|||
'data': [ |
|||
'views/sale_order_views.xml', |
|||
'views/sale_order_templates.xml', |
|||
], |
|||
'images': ['static/description/banner.png'], |
|||
'license': 'AGPL-3', |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'application': False, |
|||
} |
@ -0,0 +1,6 @@ |
|||
## Module <sale_delivery_address> |
|||
|
|||
#### 11.12.2024 |
|||
#### Version 18.0.1.0.0 |
|||
#### ADD |
|||
- Initial Commit for Multiple Delivery Addresses for Sale Order |
@ -0,0 +1,24 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Anzil K A (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 sale_order_line |
|||
from . import stock_move |
|||
from . import stock_rule |
@ -0,0 +1,46 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Anzil K A (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 api, fields, models |
|||
|
|||
|
|||
class SaleOrderLine(models.Model): |
|||
""" Inherits sale.order.line to add the new fields for delivery address """ |
|||
|
|||
_inherit = 'sale.order.line' |
|||
|
|||
delivery_addr_id = fields.Many2one( |
|||
'res.partner', string="Delivery Address", |
|||
domain="[('parent_id', '=', order_partner_id)]", |
|||
help="You can select from the delivery addresses of the same customer") |
|||
is_address_readonly = fields.Boolean(string='Address Readonly', |
|||
default=False, compute="_compute_is_address_readonly", |
|||
help='Helps find address is readonly or not') |
|||
|
|||
@api.depends('product_id') |
|||
def _compute_is_address_readonly(self): |
|||
""" This function will compute the is_address_readonly field. |
|||
The field is used to make delivery address field in sale order line |
|||
a readonly field if the product is a service.""" |
|||
for rec in self: |
|||
rec.is_address_readonly = False |
|||
if rec.product_id.type == 'service': |
|||
rec.is_address_readonly = True |
@ -0,0 +1,129 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Anzil K A (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 models |
|||
from odoo.tools.float_utils import float_compare |
|||
from odoo.tools.misc import groupby |
|||
|
|||
|
|||
class StockMove(models.Model): |
|||
""" Inherits stock_move to manage pickings with respect to the |
|||
delivery address """ |
|||
|
|||
_inherit = "stock.move" |
|||
|
|||
def _get_new_picking_values(self): |
|||
""" Extending _get_new_picking_values to create values for new |
|||
pickings with different delivery addresses""" |
|||
origins = self.filtered(lambda m: m.origin).mapped('origin') |
|||
origins = list(dict.fromkeys(origins)) |
|||
if len(origins) == 0: |
|||
origin = False |
|||
else: |
|||
origin = ','.join(origins[:5]) |
|||
if len(origins) > 5: |
|||
origin += "..." |
|||
orders = self.env['sale.order'].search([('name', 'in', origins)]) |
|||
for rec in orders: |
|||
address = [rec.partner_id.id] |
|||
for line in rec.order_line: |
|||
if line.delivery_addr_id: |
|||
if line.delivery_addr_id.id not in address: |
|||
address.append(line.delivery_addr_id.id) |
|||
elif rec.partner_id.id not in address: |
|||
address.append(rec.partner_id.id) |
|||
# if no delivery address is selected for order lines, |
|||
# only one transfer will be created |
|||
if len(address) <= 1: |
|||
res = super(StockMove, self)._get_new_picking_values() |
|||
return res |
|||
return { |
|||
'origin': origin, |
|||
'company_id': self.mapped('company_id').id, |
|||
'user_id': False, |
|||
'move_type': self.mapped('group_id').move_type or 'direct', |
|||
'partner_id': self.sale_line_id.delivery_addr_id.id or |
|||
self.sale_line_id.order_id.partner_id.id, |
|||
'picking_type_id': self.mapped('picking_type_id').id, |
|||
'location_id': self.mapped('location_id').id, |
|||
'location_dest_id': self.mapped('location_dest_id').id, |
|||
} |
|||
|
|||
def _assign_picking(self): |
|||
""" Extending _assign_picking function to create new pickings for |
|||
order lines having different delivery addresses. """ |
|||
picking_obj = self.env['stock.picking'] |
|||
grouped_moves = groupby(self, key=lambda m: m._key_assign_picking()) |
|||
for group, moves in grouped_moves: |
|||
moves = self.env['stock.move'].concat(*moves) |
|||
picking = moves[0]._search_picking_for_assignation() |
|||
if picking: |
|||
vals = {} |
|||
if any(picking.partner_id.id != move.partner_id.id for move in |
|||
moves): |
|||
vals['partner_id'] = False |
|||
if any(picking.origin != move.origin for move in moves): |
|||
vals['origin'] = False |
|||
if vals: |
|||
picking.write(vals) |
|||
else: |
|||
moves = moves.filtered( |
|||
lambda m: float_compare( |
|||
m.product_uom_qty, 0.0, |
|||
precision_rounding=m.product_uom.rounding) >= 0) |
|||
if not moves: |
|||
continue |
|||
new_picking = True |
|||
origins = moves[0].origin |
|||
orders = self.env['sale.order'].search( |
|||
[('name', '=', origins)]) |
|||
for rec in orders: |
|||
addr = [rec.partner_id.id] |
|||
for line in rec.order_line: |
|||
if line.delivery_addr_id and line.delivery_addr_id.id \ |
|||
not in addr: |
|||
addr.append(line.delivery_addr_id.id) |
|||
elif line.delivery_addr_id and rec.partner_id.id not \ |
|||
in addr: |
|||
addr.append(rec.partner_id.id) |
|||
if len(addr) <= 1: |
|||
return super(StockMove, self)._assign_picking() |
|||
else: |
|||
for mov in moves: |
|||
mov.write({ |
|||
'partner_id': |
|||
mov.sale_line_id.delivery_addr_id.id |
|||
or mov.sale_line_id.order_id.partner_id.id |
|||
}) |
|||
move_ids = [] |
|||
for index, value in enumerate(addr): |
|||
for mov in moves: |
|||
if mov.partner_id.id == value: |
|||
move_ids.append(mov.id) |
|||
mvs = self.env['stock.move'].search( |
|||
[('id', 'in', move_ids)]) |
|||
move_ids = [] |
|||
if mvs: |
|||
picking = picking_obj.create( |
|||
mvs._get_new_picking_values()) |
|||
mvs.write({'picking_id': picking.id}) |
|||
mvs._assign_picking_post_process(new=new_picking) |
|||
return True |
@ -0,0 +1,53 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Anzil K A (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 models |
|||
|
|||
|
|||
class StockRule(models.Model): |
|||
"""Inherits the stock.rule to update each move with the partner from |
|||
corresponding sale order line""" |
|||
|
|||
_inherit = 'stock.rule' |
|||
|
|||
def _get_stock_move_values(self, product_id, product_qty, product_uom, |
|||
location_id, name, origin, company_id, values): |
|||
""" Extending the _get_stock_move_values function for updating the |
|||
partner as the partner from the selected delivery address if it exists |
|||
or the partner from the order. Returns a dictionary of values that will |
|||
be used to create a stock move from a procurement. |
|||
:param procurement: browse record |
|||
:rtype: dictionary """ |
|||
res = super()._get_stock_move_values( |
|||
product_id, product_qty, product_uom, location_id, name, origin, |
|||
company_id, values) |
|||
if res.get('warehouse_id'): |
|||
warehouse = self.env['stock.warehouse'].browse(res.get( |
|||
'warehouse_id')) |
|||
if res.get('order_id') and warehouse.delivery_steps in [ |
|||
'pick_ship', 'ship_only']: |
|||
for data in res.get('order_id'): |
|||
for move in self.env['stock.move'].browse(data[-1]): |
|||
partner_id = move.sale_line_id.delivery_addr.id or \ |
|||
move.sale_line_id.order_id.partner_id.id |
|||
res.update({ |
|||
'partner_id': partner_id |
|||
}) |
|||
return res |
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: 80 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 565 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 967 B |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 112 KiB |
After Width: | Height: | Size: 258 KiB |
After Width: | Height: | Size: 690 KiB |