10 changed files with 204 additions and 0 deletions
			
			
		@ -0,0 +1 @@ | 
				
			|||||
 | 
					import models | 
				
			||||
@ -0,0 +1,34 @@ | 
				
			|||||
 | 
					# -*- encoding: utf-8 -*- | 
				
			||||
 | 
					############################################################################## | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    Item number | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    Copyright (C) 2016 Cybrosys Techno Solutions (<http://http://www.cybrosys.com). | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    This program is free software: you can redistribute it and/or modify | 
				
			||||
 | 
					#    it under the terms of the GNU Affero General Public License as | 
				
			||||
 | 
					#    published by the Free Software Foundation, either version 3 of the | 
				
			||||
 | 
					#    License, or (at your option) any later version. | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    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 for more details. | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    You should have received a copy of the GNU Affero General Public License | 
				
			||||
 | 
					#    along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
				
			||||
 | 
					# | 
				
			||||
 | 
					############################################################################## | 
				
			||||
 | 
					{ | 
				
			||||
 | 
					    '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 | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1 @@ | 
				
			|||||
 | 
					import splitter | 
				
			||||
@ -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 | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					       } | 
				
			||||
| 
		 After Width: | Height: | Size: 140 KiB  | 
@ -0,0 +1,48 @@ | 
				
			|||||
 | 
					<section class="oe_container"> | 
				
			||||
 | 
					    <div class="oe_row oe_spaced"> | 
				
			||||
 | 
					        <h2 class="oe_slogan">Split Sale Quotation</h2> | 
				
			||||
 | 
					        <h3 class="oe_slogan">Split Quotation Button</h3> | 
				
			||||
 | 
					        <div class="oe_span6"> | 
				
			||||
 | 
					            <div class="oe_demo oe_picture oe_screenshot"> | 
				
			||||
 | 
									<img src="screen1.png" alt="Online Demo"> | 
				
			||||
 | 
					            </div> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					        <div class="oe_span6"> | 
				
			||||
 | 
					            <p class='oe_mt32'> | 
				
			||||
 | 
					                Split the quotations by clicking the split order | 
				
			||||
 | 
					                button. | 
				
			||||
 | 
					            </p> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</section> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					<section class="oe_container oe_dark"> | 
				
			||||
 | 
					    <h3 class="oe_slogan">Split Confirm Wizard</h3> | 
				
			||||
 | 
					    <div class="oe_row"> | 
				
			||||
 | 
					        <div class="oe_span6"> | 
				
			||||
 | 
					            <p class='oe_mt32'> | 
				
			||||
 | 
					                Enter the count to be split from quotation order-line. | 
				
			||||
 | 
					            </p> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					        <div class="oe_span6"> | 
				
			||||
 | 
					            <img class="oe_picture oe_screenshot" src="screen2.png"> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</section> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					<section class="oe_container"> | 
				
			||||
 | 
					    <h3 class="oe_slogan">Naming The Sale Quotations After Split </h3> | 
				
			||||
 | 
					    <div class="oe_row"> | 
				
			||||
 | 
					        <div class="oe_span6"> | 
				
			||||
 | 
					            <img class="oe_picture oe_screenshot" src="screen3.png"> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					        <div class="oe_span6"> | 
				
			||||
 | 
					            <p class='oe_mt32'> | 
				
			||||
 | 
					                All the quotations split from a sale order have the name | 
				
			||||
 | 
					                as count followed by the parent sale order. | 
				
			||||
 | 
					            </p> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</section> | 
				
			||||
 | 
					
 | 
				
			||||
| 
		 After Width: | Height: | Size: 353 KiB  | 
| 
		 After Width: | Height: | Size: 271 KiB  | 
| 
		 After Width: | Height: | Size: 136 KiB  | 
@ -0,0 +1,29 @@ | 
				
			|||||
 | 
					<openerp> | 
				
			||||
 | 
					    <data> | 
				
			||||
 | 
					        <record id="button_wizard" model="ir.ui.view"> | 
				
			||||
 | 
					            <field name="name">button.wizard</field> | 
				
			||||
 | 
					            <field name="model">split.button.wiz</field> | 
				
			||||
 | 
					            <field name="arch" type="xml"> | 
				
			||||
 | 
					                <form> | 
				
			||||
 | 
					                    <p>Enter number of order lines by the order of which the sale order to be split .</p> | 
				
			||||
 | 
					                    <group> <group><field name="line_count"/></group><group></group></group> | 
				
			||||
 | 
					                    <footer> | 
				
			||||
 | 
					                        <button name="confirm_split" type="object" string="Split" class="oe_highlight"/> | 
				
			||||
 | 
					                        <button string="Cancel" class="btn-default" special="cancel" /> | 
				
			||||
 | 
					                    </footer> | 
				
			||||
 | 
					                </form> | 
				
			||||
 | 
					            </field> | 
				
			||||
 | 
					        </record> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					        <record id="sale_split_button" model="ir.ui.view"> | 
				
			||||
 | 
					            <field name="name">sale_split_button</field> | 
				
			||||
 | 
					            <field name="model">sale.order</field> | 
				
			||||
 | 
					            <field name="inherit_id" ref="sale.view_order_form"/> | 
				
			||||
 | 
					            <field name="arch" type="xml"> | 
				
			||||
 | 
					                <xpath expr="//field[@name='state']" position="before"> | 
				
			||||
 | 
					                    <button name="button_split" type="object" states="draft" string="Split Quotation" attrs="{'invisible': [('state','not in', ('draft'))]}"/> | 
				
			||||
 | 
					                </xpath> | 
				
			||||
 | 
					            </field> | 
				
			||||
 | 
					        </record> | 
				
			||||
 | 
					    </data> | 
				
			||||
 | 
					</openerp> | 
				
			||||
					Loading…
					
					
				
		Reference in new issue