@ -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 |
|||
|
|||
Sale Recurring |
|||
============== |
|||
* Create sale orders automatically based on recurring orders module for Odoo 17. |
|||
|
|||
Configuration |
|||
============= |
|||
- No additional configuration is required |
|||
|
|||
License |
|||
------- |
|||
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 |
|||
------- |
|||
* Developer: (V18) Ammu Raj, |
|||
(V17) Mufeeda Shirin |
|||
(V16) Sruthi MK |
|||
Contact : odoo@cybrosys.com |
|||
|
|||
Contacts |
|||
-------- |
|||
* Mail Contact : odoo@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: 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,46 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################### |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-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': 'Sale Recurring', |
|||
'version': '18.0.1.0.0', |
|||
'category': 'Sales', |
|||
'summary': 'Automatic sale order creation based on recurring orders', |
|||
'description': 'This module is helps to create sale orders automatically ' |
|||
'based on the recurring orders.', |
|||
'author': 'Cybrosys Techno solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'maintainer': 'Cybrosys Techno Solutions', |
|||
'website': 'https://www.cybrosys.com', |
|||
'depends': ['account', 'sale_management'], |
|||
'data': [ |
|||
'data/ir_sequence_data.xml', |
|||
'data/ir_cron_data.xml', |
|||
'security/ir.model.access.csv', |
|||
'views/sale_recurring_views.xml', |
|||
'views/sale_order_views.xml' |
|||
], |
|||
'images': ['static/description/banner.jpg'], |
|||
'license': 'AGPL-3', |
|||
'installable': True, |
|||
'application': False, |
|||
'auto_install': False, |
|||
} |
@ -0,0 +1,18 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<data noupdate="1"> |
|||
<!--Cron job for Sale Recurring--> |
|||
<record forcecreate="True" |
|||
id="ir_cron_create_sale_order_scheduler_action" |
|||
model="ir.cron"> |
|||
<field name="name">Sale Recurring</field> |
|||
<field name="model_id" ref="model_sale_recurring"/> |
|||
<field name="state">code</field> |
|||
<field name="code">model.cron_sale_order_creation()</field> |
|||
<field name="user_id" ref="base.user_root"/> |
|||
<field name="interval_number">1</field> |
|||
<field name="interval_type">days</field> |
|||
<field name="active" eval="True"/> |
|||
</record> |
|||
</data> |
|||
</odoo> |
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<odoo> |
|||
<data noupdate="1"> |
|||
<!-- Sale recurring sequence creation template--> |
|||
<record id="sequence_order" model="ir.sequence"> |
|||
<field name="name">Sequence Order</field> |
|||
<field name="code">sequence.order</field> |
|||
<field name="prefix">SR</field> |
|||
<field name="padding">3</field> |
|||
</record> |
|||
</data> |
|||
</odoo> |
@ -0,0 +1,7 @@ |
|||
## Module <sale_recurring> |
|||
|
|||
#### 12.12.2024 |
|||
#### Version 18.0.1.0.0 |
|||
#### ADD |
|||
|
|||
- Initial Commit for Sale Recurring |
@ -0,0 +1,24 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################### |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-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 sale_order |
|||
from . import sale_recurring |
|||
from . import sale_recurring_line |
@ -0,0 +1,31 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################### |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-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 SaleOrder(models.Model): |
|||
"""Inheriting SaleOrder to add a new field for recurring orders""" |
|||
_inherit = 'sale.order' |
|||
|
|||
recurring_order_id = fields.Many2one('sale.recurring', |
|||
string='Recurring Order', |
|||
help='Sale recurring order details') |
@ -0,0 +1,157 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################### |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-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 datetime import timedelta |
|||
from odoo import api, fields, models |
|||
|
|||
|
|||
class SaleRecurring(models.Model): |
|||
"""Helps to create a recurring sale order""" |
|||
_name = 'sale.recurring' |
|||
_description = 'Sale Order Recurring' |
|||
_inherit = ['mail.thread', 'mail.activity.mixin'] |
|||
|
|||
name = fields.Char(string="Name", readonly=True, copy=False, default='New', |
|||
help="Sequence of recurring order") |
|||
title = fields.Char(string='Title', help="Name of the order") |
|||
partner_id = fields.Many2one('res.partner', string='Customer', |
|||
required=True, help="Customer name") |
|||
start_date = fields.Date(string='Start Date', required=True, |
|||
help=" Start the sale order creation based on the" |
|||
" start date") |
|||
stop_after = fields.Integer(string='Stop After', |
|||
help='Total days to end the sale order' |
|||
'creation') |
|||
end_date = fields.Date(string='End Date', readonly=True, |
|||
help='Stop the sale order creation based on ' |
|||
'the end date', tracking=True) |
|||
state = fields.Selection(selection=[('running', 'Running'), |
|||
('expired', 'Expired'), |
|||
('cancelled', 'Cancelled')], |
|||
string='Status', copy=False, default='running', |
|||
help='State of recurring order', tracking=True) |
|||
total_sale_order = fields.Integer(string="Total SO", |
|||
compute='_compute_total_sale_order', |
|||
help='Count of total sale orders') |
|||
total_sale_quotation = fields.Integer(string="Total RFQ", |
|||
compute='_compute_total_sale_quotation', |
|||
help='Count of total quotations') |
|||
active = fields.Boolean(default=True, string='Active', tracking=True, |
|||
help='If unchecked, it will allow you to hide the' |
|||
' recurring order without removing it.') |
|||
order_line_ids = fields.One2many('sale.recurring.line', 'order_id', |
|||
string="Order lines", |
|||
help='To store recurring order datas') |
|||
|
|||
@api.model_create_multi |
|||
def create(self, vals_list): |
|||
"""Sequence creation of recurring order.""" |
|||
for vals in vals_list: |
|||
vals['name'] = self.env['ir.sequence'].next_by_code('sequence.order') |
|||
return super().create(vals_list) |
|||
|
|||
@api.onchange('stop_after', 'start_date') |
|||
def _onchange_start_date(self): |
|||
"""Update end date based on the start_date and stop_after""" |
|||
self.end_date = 0 |
|||
if self.stop_after > 0: |
|||
self.end_date = self.start_date + timedelta(days=self.stop_after) |
|||
|
|||
def action_create_sale_order(self): |
|||
"""Create sale order from the created sale recurring""" |
|||
line_vals = [fields.Command.create({'product_id': rec.product_id.id, |
|||
'product_uom_qty': rec.product_uom_qty, |
|||
'price_unit': rec.price_unit, |
|||
'name': rec.name}) for rec in |
|||
self.order_line_ids] |
|||
if line_vals: |
|||
self.env['sale.order'].sudo().create({ |
|||
'partner_id': self.partner_id.id, |
|||
'recurring_order_id': self.id, |
|||
'order_line': line_vals |
|||
}) |
|||
|
|||
def action_cancel_recurring_order(self): |
|||
"""Cancel recurring orders if not necessary""" |
|||
self.state = 'cancelled' |
|||
|
|||
def action_renew(self): |
|||
"""Renew the recurring order if they are cancelled.""" |
|||
self.state = 'running' |
|||
|
|||
def cron_sale_order_creation(self): |
|||
"""Create sale orders automatically while checking the conditions |
|||
of start date and end date""" |
|||
recurring_data = self.env['sale.recurring'].search([]) |
|||
for rec in recurring_data: |
|||
if rec.end_date and rec.end_date < fields.Date.today(): |
|||
rec.state = 'expired' |
|||
if rec.state == 'running': |
|||
if rec.end_date and rec.start_date <= fields.Date.today() <= rec.end_date: |
|||
rec.action_create_sale_order() |
|||
elif rec.start_date <= fields.Date.today(): |
|||
rec.action_create_sale_order() |
|||
|
|||
def action_get_sale_orders(self): |
|||
"""Get total sale orders in sale recurring smart button""" |
|||
return { |
|||
'type': 'ir.actions.act_window', |
|||
'name': 'reservation', |
|||
'view_mode': 'list,form', |
|||
'res_model': 'sale.order', |
|||
'domain': [('recurring_order_id', '=', self.id), |
|||
('state', '=', 'sale')], |
|||
} |
|||
|
|||
def action_get_sale_quotations(self): |
|||
"""Get total sale quotations in sale recurring smart button""" |
|||
return { |
|||
'type': 'ir.actions.act_window', |
|||
'name': 'reservation', |
|||
'view_mode': 'list,form', |
|||
'res_model': 'sale.order', |
|||
'domain': [('recurring_order_id', '=', self.id), |
|||
('state', 'in', ['draft', 'sent'])], |
|||
} |
|||
|
|||
def _compute_total_sale_order(self): |
|||
"""Compute total number of sale orders""" |
|||
for record in self: |
|||
record.total_sale_order = self.env[ |
|||
'sale.order'].search_count( |
|||
[('recurring_order_id', '=', record.id), |
|||
('state', '=', 'sale')]) |
|||
|
|||
def _compute_total_sale_quotation(self): |
|||
"""Compute total number of quotations.""" |
|||
for record in self: |
|||
record.total_sale_quotation = self.env[ |
|||
'sale.order'].search_count( |
|||
[('recurring_order_id', '=', record.id), |
|||
('state', 'in', ['draft', 'sent'])]) |
|||
|
|||
def action_archive_orders(self): |
|||
"""Archive recurring orders""" |
|||
self.active = False |
|||
|
|||
def action_unarchive_orders(self): |
|||
"""Un archive recurring orders""" |
|||
self.active = True |
@ -0,0 +1,42 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################### |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-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 SaleRecurringLine(models.Model): |
|||
"""SaleRecurringLine class represents a recurring order line""" |
|||
_name = 'sale.recurring.line' |
|||
_description = 'Recurring Line' |
|||
|
|||
product_id = fields.Many2one('product.product', string='Product', |
|||
required=True, |
|||
help='Select a product for which the sale' |
|||
' recurring will be used') |
|||
name = fields.Char(string='Description', related='product_id.name', |
|||
help='Name of the product') |
|||
price_unit = fields.Float(string='Price', |
|||
related='product_id.list_price', |
|||
help='Product price') |
|||
product_uom_qty = fields.Float(string='Quantity', default=1, |
|||
help='Total number of quantity') |
|||
order_id = fields.Many2one('sale.recurring', string="Order", |
|||
help='Order details') |
|
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: 317 KiB |
After Width: | Height: | Size: 57 KiB |
After Width: | Height: | Size: 84 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 137 KiB |
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 719 KiB |