@ -0,0 +1,49 @@ |
|||||
|
.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg |
||||
|
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html |
||||
|
:alt: License: LGPL-3 |
||||
|
|
||||
|
Sale/Purchase Orders from Products |
||||
|
=================================== |
||||
|
Sale/Purchase Orders from Product variants. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
* No additional configuration is needed. |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
Lesser General Public License, Version 3 (LGPL v3). |
||||
|
(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
* Developers : (V16) Neethu UM, |
||||
|
(V17) Sabeel B, |
||||
|
(V18) Aysha Shalin |
||||
|
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: Aysha Shalin (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from . import wizard |
@ -0,0 +1,46 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
{ |
||||
|
'name': 'Sale/Purchase Orders from Products', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Sales/Purchases', |
||||
|
'summary': 'Sale/Purchase Orders from Product Variant Tree View', |
||||
|
'description': """This module will help to create new sale/purchase orders |
||||
|
using the selected products and it will add the selected products to draft |
||||
|
orders.""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': "https://www.cybrosys.com", |
||||
|
'depends': ['sale_management', 'purchase'], |
||||
|
'data': [ |
||||
|
'security/ir.model.access.csv', |
||||
|
'wizard/quick_sale_order_views.xml', |
||||
|
'wizard/quick_purchase_order_views.xml', |
||||
|
'views/product_product_views.xml' |
||||
|
], |
||||
|
'images': ['static/description/banner.png'], |
||||
|
'license': 'LGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
## Module <sale_purchase_from_product> |
||||
|
|
||||
|
#### 05.11.2024 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
##### ADD |
||||
|
- Initial commit for Sale/Purchase Orders from Products |
|
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: 124 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 118 KiB |
After Width: | Height: | Size: 84 KiB |
After Width: | Height: | Size: 119 KiB |
After Width: | Height: | Size: 193 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 9.4 KiB |
@ -0,0 +1,15 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<!-- Inherit and add new buttons in product_product list view --> |
||||
|
<record id="product_product_quick_create_list_view" model="ir.ui.view"> |
||||
|
<field name="name">product.product.view.tree.inherit.sale.purchase.from.product</field> |
||||
|
<field name="model">product.product</field> |
||||
|
<field name="inherit_id" ref="product.product_product_tree_view"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//header/button[@name='action_open_label_layout']" position="after"> |
||||
|
<button string="Quick Sale Order" name="%(sale_purchase_from_product.quick_sale_purchase_wizard_action)d" type="action"/> |
||||
|
<button string="Quick Purchase Order" name="%(sale_purchase_from_product.quick_purchase_order_action)d" type="action"/> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
</odoo> |
@ -0,0 +1,25 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from . import quick_create_sale_line |
||||
|
from . import quick_purchase_line |
||||
|
from . import quick_purchase_order |
||||
|
from . import quick_sale_order |
@ -0,0 +1,39 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from odoo import fields, models |
||||
|
|
||||
|
|
||||
|
class QuickSaleOrderLines(models.TransientModel): |
||||
|
"""OrderLine for quick sale order""" |
||||
|
_name = 'quick.sale.line' |
||||
|
_description = 'Quick Sale Line' |
||||
|
|
||||
|
product_id = fields.Many2one('product.product', |
||||
|
string='Product', required=True, |
||||
|
help="Products") |
||||
|
product_uom_qty = fields.Float(string="Quantity", help="Product Quantity") |
||||
|
price_unit = fields.Float(string="Unit Price", required=True, |
||||
|
help="Product unit price") |
||||
|
tax_id = fields.Many2many(comodel_name='account.tax', string="Taxes", |
||||
|
help="Choose taxes for the products") |
||||
|
order_id = fields.Many2one('quick.sale.order', |
||||
|
string="Order", help="Created sale order") |
@ -0,0 +1,38 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from odoo import fields, models |
||||
|
|
||||
|
|
||||
|
class QuickPurchaseOrderLines(models.TransientModel): |
||||
|
"""OrderLine for quick purchase order""" |
||||
|
_name = 'quick.purchase.line' |
||||
|
_description = 'Quick Purchase Line' |
||||
|
|
||||
|
order_id = fields.Many2one('quick.purchase.order') |
||||
|
product_id = fields.Many2one('product.product', |
||||
|
string='Product', required=True, |
||||
|
help="Product") |
||||
|
product_qty = fields.Float(string="Quantity", help="Product quantity") |
||||
|
price_unit = fields.Float(string="Unit Price", required=True, |
||||
|
help="Product unit price") |
||||
|
tax_id = fields.Many2many(comodel_name='account.tax', string="Taxes", |
||||
|
help="Tax for the products") |
@ -0,0 +1,112 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from odoo import api, fields, models |
||||
|
|
||||
|
|
||||
|
class QuickPurchaseOrder(models.TransientModel): |
||||
|
"""Quick purchase_order create wizard""" |
||||
|
_name = 'quick.purchase.order' |
||||
|
_description = 'Quick Purchase Order' |
||||
|
|
||||
|
def _purchase_ids_domain(self): |
||||
|
""" List out only the draft and sent orders """ |
||||
|
return [('state', 'in', ['draft', 'sent'])] |
||||
|
|
||||
|
type = fields.Selection([('new_order', 'Create New Order'), |
||||
|
('existing_order', 'Add to existing Orders')], |
||||
|
required=True, default='new_order', |
||||
|
help="Choose between new order and existing") |
||||
|
partner_id = fields.Many2one('res.partner', string="Vendor", |
||||
|
help="Choose the customer") |
||||
|
order_date = fields.Datetime(string="Order Date", help="Set order date") |
||||
|
user_id = fields.Many2one('res.users', |
||||
|
default=lambda self: self.env.user, |
||||
|
required=True, string="Buyer", |
||||
|
help="Choose payment term for the order") |
||||
|
line_ids = fields.One2many('quick.purchase.line', |
||||
|
'order_id', string="Sale Order Line", |
||||
|
help="Add orderlines") |
||||
|
purchase_ids = fields.Many2many('purchase.order', |
||||
|
string="Purchase Orders", |
||||
|
domain=_purchase_ids_domain, |
||||
|
help="Choose purchase orders to update") |
||||
|
|
||||
|
@api.model |
||||
|
def default_get(self, fields): |
||||
|
res = super(QuickPurchaseOrder, self).default_get(fields) |
||||
|
active_records = self.env.context.get('active_ids', []) |
||||
|
products = self.env['product.product'].search([ |
||||
|
('id', 'in', active_records)]) |
||||
|
wizard_line = [(5, 0, 0)] |
||||
|
for rec in products: |
||||
|
line = (0, 0, { |
||||
|
'product_id': rec.id, |
||||
|
'product_qty': 1, |
||||
|
'price_unit': rec.lst_price, |
||||
|
'tax_id': rec.taxes_id.ids, |
||||
|
}) |
||||
|
wizard_line.append(line) |
||||
|
res.update({ |
||||
|
'line_ids': wizard_line}) |
||||
|
return res |
||||
|
|
||||
|
def action_create(self): |
||||
|
"""Creates purchase order""" |
||||
|
order = self.env['purchase.order'].sudo().create({ |
||||
|
'partner_id': self.partner_id.id, |
||||
|
'date_order': self.order_date if self.order_date else |
||||
|
fields.datetime.now(), |
||||
|
'user_id': self.user_id.id, |
||||
|
'order_line': [(0, 0, { |
||||
|
'product_id': rec.product_id.id, |
||||
|
'product_qty': rec.product_qty, |
||||
|
'price_unit': rec.price_unit, |
||||
|
'taxes_id': rec.tax_id.ids, |
||||
|
}) for rec in self.line_ids] |
||||
|
}) |
||||
|
return order |
||||
|
|
||||
|
def action_update_order(self): |
||||
|
"""Update the products to existing orders""" |
||||
|
for order in self.purchase_ids: |
||||
|
order.update({ |
||||
|
'order_line': [(0, 0, { |
||||
|
'product_id': rec.product_id.id, |
||||
|
'product_qty': rec.product_qty, |
||||
|
'price_unit': rec.price_unit, |
||||
|
'taxes_id': rec.tax_id.ids, |
||||
|
}) for rec in self.line_ids] |
||||
|
}) |
||||
|
|
||||
|
def action_create_view(self): |
||||
|
"""Create and view the created orders""" |
||||
|
order = self.action_create() |
||||
|
view = self.env['ir.model.data']._xmlid_lookup( |
||||
|
'purchase.purchase_order_form')[1] |
||||
|
return { |
||||
|
'type': 'ir.actions.act_window', |
||||
|
'res_model': 'purchase.order', |
||||
|
'res_id': order.id, |
||||
|
'view_mode': 'form', |
||||
|
'views': [(False, "form")], |
||||
|
'view_id': view, |
||||
|
} |
@ -0,0 +1,64 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<!-- Quick purchase wizard form view --> |
||||
|
<record id="quick_purchase_order_view_form" model="ir.ui.view"> |
||||
|
<field name="name">Quick Purchase Order Create</field> |
||||
|
<field name="model">quick.purchase.order</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Quick Create"> |
||||
|
<group> |
||||
|
<field name="type" widget="radio"/> |
||||
|
</group> |
||||
|
<group> |
||||
|
<group> |
||||
|
<field name="partner_id" |
||||
|
invisible="type == 'existing_order'"/> |
||||
|
<field name="purchase_ids" widget="many2many_tags" |
||||
|
invisible="type == 'new_order'"/> |
||||
|
</group> |
||||
|
<group> |
||||
|
<field name="order_date" |
||||
|
invisible="type == 'existing_order'"/> |
||||
|
<field name="user_id" |
||||
|
invisible="type == 'existing_order'"/> |
||||
|
</group> |
||||
|
</group> |
||||
|
<notebook> |
||||
|
<page string="Order Line"> |
||||
|
<field name="line_ids"> |
||||
|
<list editable="bottom"> |
||||
|
<field name="product_id"/> |
||||
|
<field name="product_qty"/> |
||||
|
<field name="price_unit"/> |
||||
|
<field name="tax_id" widget="many2many_tags"/> |
||||
|
</list> |
||||
|
</field> |
||||
|
</page> |
||||
|
</notebook> |
||||
|
<footer> |
||||
|
<button name="action_create" type="object" string="Create" |
||||
|
class="oe_highlight" |
||||
|
confirm="Purchase order created successfully" |
||||
|
invisible="type == 'existing_order'"/> |
||||
|
<button name="action_update_order" type="object" |
||||
|
string="Update Order" class="oe_highlight" |
||||
|
confirm="Purchase orders updated successfully" |
||||
|
invisible="type == 'new_order'"/> |
||||
|
<button name="action_create_view" type="object" |
||||
|
string="Create and View" class="oe_highlight" |
||||
|
invisible="type == 'existing_order'"/> |
||||
|
<button string="Cancel" class="oe_link" special="cancel" |
||||
|
confirm="Do you want to Discard?"/> |
||||
|
</footer> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<!-- Quick purchase wizard action --> |
||||
|
<record id="quick_purchase_order_action" model="ir.actions.act_window"> |
||||
|
<field name="name">Purchase Quick Create</field> |
||||
|
<field name="res_model">quick.purchase.order</field> |
||||
|
<field name="view_mode">form</field> |
||||
|
<field name="target">new</field> |
||||
|
</record> |
||||
|
</odoo> |
@ -0,0 +1,115 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
from odoo import api, fields, models |
||||
|
|
||||
|
|
||||
|
class QuickCreateOrder(models.TransientModel): |
||||
|
"""Quick sale_order create wizard""" |
||||
|
_name = 'quick.sale.order' |
||||
|
_description = 'Quick Sale Order' |
||||
|
|
||||
|
def _sale_ids_domain(self): |
||||
|
"""List out only the draft orders""" |
||||
|
return [('state', 'in', ['draft', 'sent'])] |
||||
|
|
||||
|
type = fields.Selection([('new_order', 'Create New Order'), |
||||
|
('existing_order', 'Add to existing Orders')], |
||||
|
required=True, default='new_order', |
||||
|
help="Choose between new order and existing") |
||||
|
partner_id = fields.Many2one('res.partner', string="Customer", |
||||
|
help="Choose the customer") |
||||
|
order_date = fields.Datetime(string="Order Date", help="Set order date") |
||||
|
payment_term_id = fields.Many2one('account.payment.term', |
||||
|
string="Payment Terms", |
||||
|
help="Choose payment term for the order") |
||||
|
user_id = fields.Many2one('res.users', string="Salesperson", |
||||
|
default=lambda self: self.env.user, required=True, |
||||
|
help="Assigned salesperson") |
||||
|
line_ids = fields.One2many('quick.sale.line', |
||||
|
'order_id', string="Sale Order Line", |
||||
|
help="Add orderlines") |
||||
|
sale_ids = fields.Many2many('sale.order', string="Sale Orders", |
||||
|
domain=_sale_ids_domain, |
||||
|
help="Choose sale orders to update") |
||||
|
|
||||
|
@api.model |
||||
|
def default_get(self, fields): |
||||
|
"""Default values""" |
||||
|
res = super(QuickCreateOrder, self).default_get(fields) |
||||
|
active_records = self.env.context.get('active_ids', []) |
||||
|
products = self.env['product.product'].search([ |
||||
|
('id', 'in', active_records)]) |
||||
|
wizard_line = [(5, 0, 0)] |
||||
|
for rec in products: |
||||
|
line = (0, 0, { |
||||
|
'product_id': rec.id, |
||||
|
'product_uom_qty': 1, |
||||
|
'price_unit': rec.lst_price, |
||||
|
'tax_id': rec.taxes_id.ids, |
||||
|
}) |
||||
|
wizard_line.append(line) |
||||
|
res.update({ |
||||
|
'line_ids': wizard_line}) |
||||
|
return res |
||||
|
|
||||
|
def action_update_order(self): |
||||
|
"""Update Sale Order""" |
||||
|
for order in self.sale_ids: |
||||
|
order.update({ |
||||
|
'order_line': [(0, 0, { |
||||
|
'product_id': rec.product_id.id, |
||||
|
'product_uom_qty': rec.product_uom_qty, |
||||
|
'price_unit': rec.price_unit, |
||||
|
'tax_id': rec.tax_id.ids, |
||||
|
}) for rec in self.line_ids] |
||||
|
}) |
||||
|
|
||||
|
def action_create(self): |
||||
|
"""Create Sale Order""" |
||||
|
order = self.env['sale.order'].sudo().create({ |
||||
|
'partner_id': self.partner_id.id, |
||||
|
'date_order': self.order_date if self.order_date else |
||||
|
fields.datetime.now(), |
||||
|
'user_id': self.user_id.id, |
||||
|
'payment_term_id': self.payment_term_id.id, |
||||
|
'order_line': [(0, 0, { |
||||
|
'product_id': rec.product_id.id, |
||||
|
'product_uom_qty': rec.product_uom_qty, |
||||
|
'price_unit': rec.price_unit, |
||||
|
'tax_id': rec.tax_id.ids, |
||||
|
}) for rec in self.line_ids] |
||||
|
}) |
||||
|
return order |
||||
|
|
||||
|
def action_create_view(self): |
||||
|
"""Create and view the order created""" |
||||
|
order = self.action_create() |
||||
|
view = self.env['ir.model.data']._xmlid_lookup( |
||||
|
'sale.view_order_form')[1] |
||||
|
return { |
||||
|
'type': 'ir.actions.act_window', |
||||
|
'res_model': 'sale.order', |
||||
|
'res_id': order.id, |
||||
|
'view_mode': 'form', |
||||
|
'views': [(False, "form")], |
||||
|
'view_id': view, |
||||
|
} |
@ -0,0 +1,67 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<!-- Quick sale create wizard form view --> |
||||
|
<record id="quick_sale_order_view_form" model="ir.ui.view"> |
||||
|
<field name="name">Quick Create</field> |
||||
|
<field name="model">quick.sale.order</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Quick Create"> |
||||
|
<group> |
||||
|
<field name="type" widget="radio"/> |
||||
|
</group> |
||||
|
<group> |
||||
|
<group> |
||||
|
<field name="partner_id" |
||||
|
invisible="type == 'existing_order'"/> |
||||
|
<field name="sale_ids" widget="many2many_tags" |
||||
|
invisible="type == 'new_order'"/> |
||||
|
<field name="payment_term_id" |
||||
|
invisible="type == 'existing_order'"/> |
||||
|
</group> |
||||
|
<group> |
||||
|
<field name="order_date" |
||||
|
invisible="type == 'existing_order'"/> |
||||
|
<field name="user_id" |
||||
|
invisible="type == 'existing_order'"/> |
||||
|
</group> |
||||
|
</group> |
||||
|
<notebook> |
||||
|
<page string="Order Line"> |
||||
|
<field name="line_ids"> |
||||
|
<list editable="bottom"> |
||||
|
<field name="product_id"/> |
||||
|
<field name="product_uom_qty"/> |
||||
|
<field name="price_unit"/> |
||||
|
<field name="tax_id" widget="many2many_tags"/> |
||||
|
</list> |
||||
|
</field> |
||||
|
</page> |
||||
|
</notebook> |
||||
|
<footer> |
||||
|
<button name="action_create" type="object" string="Create" |
||||
|
class="oe_highlight" |
||||
|
confirm="Sales order created successfully" |
||||
|
invisible="type == 'existing_order'"/> |
||||
|
<button name="action_update_order" type="object" |
||||
|
string="Update Order" class="oe_highlight" |
||||
|
confirm="Sales orders updated successfully" |
||||
|
invisible="type == 'new_order'"/> |
||||
|
<button name="action_create_view" type="object" |
||||
|
string="Create and View" class="oe_highlight" |
||||
|
invisible="type == 'existing_order'"/> |
||||
|
<button string="Cancel" class="oe_link" special="cancel" |
||||
|
confirm="Do you want to Discard?"/> |
||||
|
</footer> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<!-- Quick sale wizard action --> |
||||
|
<record id="quick_sale_purchase_wizard_action" |
||||
|
model="ir.actions.act_window"> |
||||
|
<field name="name">Sale/Purchase Quick Create</field> |
||||
|
<field name="res_model">quick.sale.order</field> |
||||
|
<field name="view_mode">form</field> |
||||
|
<field name="target">new</field> |
||||
|
</record> |
||||
|
</odoo> |