diff --git a/sale_splitter/__init__.py b/sale_splitter/__init__.py new file mode 100644 index 000000000..2c4eac3f8 --- /dev/null +++ b/sale_splitter/__init__.py @@ -0,0 +1 @@ +import models \ No newline at end of file diff --git a/sale_splitter/__openerp__.py b/sale_splitter/__openerp__.py new file mode 100644 index 000000000..296d11163 --- /dev/null +++ b/sale_splitter/__openerp__.py @@ -0,0 +1,34 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Item number +# +# Copyright (C) 2016 Cybrosys Techno Solutions (. +# +############################################################################## +{ + 'name': 'SALE ORDER SPLITTER', + 'version': '1.0', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': 'http://www.cybrosys.com', + 'sequence': 6, + 'category': 'Sales Management', + 'summary': 'Used for splitting lengthy quotations into suppurate.', + 'data': ['views/splitter.xml'], + 'depends': ['base','sale'], + 'installable': True +} \ No newline at end of file diff --git a/sale_splitter/models/__init__.py b/sale_splitter/models/__init__.py new file mode 100644 index 000000000..7fd1b1960 --- /dev/null +++ b/sale_splitter/models/__init__.py @@ -0,0 +1 @@ +import splitter \ No newline at end of file diff --git a/sale_splitter/models/splitter.py b/sale_splitter/models/splitter.py new file mode 100644 index 000000000..116a62086 --- /dev/null +++ b/sale_splitter/models/splitter.py @@ -0,0 +1,91 @@ + +from openerp import fields, models, api + + +class config_bool(models.Model): + _inherit = 'sale.config.settings' + + conf_bool = fields.Boolean(string="Enables Sale order splitting") + + +class wizard(models.TransientModel): + _name = 'split.button.wiz' + temp = 1 + + line_count = fields.Char('Divide By', required=True) + + @api.one + def confirm_split(self,vals): + line_ids = [] + so_create = [] + so_id = vals['active_id'] + sale_obj = self.pool.get('sale.order').browse(self._cr, self._uid, so_id) + countt= 0 + for lines in sale_obj.order_line: + create_obt = { + 'product_id': lines.product_id.id, + 'name': lines.name, + 'product_uom_qty': lines.product_uom_qty, + 'price_unit': lines.price_unit, + 'tax_id': lines.tax_id, + 'product_uom': lines.product_uom.id, + 'price_subtotal': lines.price_subtotal + } + so_create.append((0, 0, create_obt)) + line_ids.append({'ids': lines.id}) + if len(line_ids) == int(self.line_count): + countt = countt + 1 + self.pool.get('sale.order').create(self._cr, self._uid, { + 'name': sale_obj.name + '/00' + str(countt), + 'partner_id': sale_obj.partner_id.id, + 'validity_date': sale_obj.validity_date, + 'order_line': so_create, + 'pricelist_id': sale_obj.pricelist_id.id + }) + so_create = [] + for idss in line_ids: + self._cr.execute("delete from sale_order_line where id = %s", [idss['ids']]) + line_ids = [] + self.temp = 0 + + + self.temp += 1 + counted=0 + for i in sale_obj.order_line: + counted += 1 + if counted == 0: + self._cr.execute("delete from sale_order where id = %s", [sale_obj.id]) + else: + untaxed_total = 0.0 + tax = 0.0 + for line in sale_obj.order_line: + untaxed_total += line.price_subtotal + tax += line.price_tax + + sale_obj.amount_untaxed = sale_obj.pricelist_id.currency_id.round(untaxed_total) + sale_obj.amount_tax = sale_obj.pricelist_id.currency_id.round(tax) + sale_obj.amount_total = sale_obj.amount_untaxed + sale_obj.amount_tax + + +class button_split(models.Model): + + _inherit = 'sale.order' + + + parent_id = fields.Char() + + def button_split(self, cr, uid, ids, context=None): + return { + 'name': 'Confirm Split', + + 'type': 'ir.actions.act_window', + + 'view_mode': 'form', + + 'res_model': 'split.button.wiz', + + 'target': 'new', + + 'vals': self.pool.get('sale.order').browse(cr, uid, ids).id + + } diff --git a/sale_splitter/static/description/icon.png b/sale_splitter/static/description/icon.png new file mode 100644 index 000000000..ace79d30f Binary files /dev/null and b/sale_splitter/static/description/icon.png differ diff --git a/sale_splitter/static/description/index.html b/sale_splitter/static/description/index.html new file mode 100644 index 000000000..d4ff76f2a --- /dev/null +++ b/sale_splitter/static/description/index.html @@ -0,0 +1,48 @@ +
+
+

Split Sale Quotation

+

Split Quotation Button

+
+
+ Online Demo +
+
+
+

+ Split the quotations by clicking the split order + button. +

+
+
+
+ +
+

Split Confirm Wizard

+
+
+

+ Enter the count to be split from quotation order-line. +

+
+
+ +
+
+
+ + +
+

Naming The Sale Quotations After Split

+
+
+ +
+
+

+ All the quotations split from a sale order have the name + as count followed by the parent sale order. +

+
+
+
+ diff --git a/sale_splitter/static/description/screen1.png b/sale_splitter/static/description/screen1.png new file mode 100644 index 000000000..c6973ccd8 Binary files /dev/null and b/sale_splitter/static/description/screen1.png differ diff --git a/sale_splitter/static/description/screen2.png b/sale_splitter/static/description/screen2.png new file mode 100644 index 000000000..320ad4cff Binary files /dev/null and b/sale_splitter/static/description/screen2.png differ diff --git a/sale_splitter/static/description/screen3.png b/sale_splitter/static/description/screen3.png new file mode 100644 index 000000000..c3b84de0f Binary files /dev/null and b/sale_splitter/static/description/screen3.png differ diff --git a/sale_splitter/views/splitter.xml b/sale_splitter/views/splitter.xml new file mode 100644 index 000000000..c65ab5747 --- /dev/null +++ b/sale_splitter/views/splitter.xml @@ -0,0 +1,29 @@ + + + + button.wizard + split.button.wiz + +
+

Enter number of order lines by the order of which the sale order to be split .

+ +
+
+
+
+
+ + + sale_split_button + sale.order + + + +