← Back to team overview

avanzosc team mailing list archive

[Merge] lp:~alfredodelafuente/avanzosc/dos_services_to_invoice into lp:~avanzosc-security-team/avanzosc/72horas

 

Alfredo has proposed merging lp:~alfredodelafuente/avanzosc/dos_services_to_invoice into lp:~avanzosc-security-team/avanzosc/72horas.

Requested reviews:
  Avanzosc_security (avanzosc-security-team)

For more details, see:
https://code.launchpad.net/~alfredodelafuente/avanzosc/dos_services_to_invoice/+merge/224422
-- 
https://code.launchpad.net/~alfredodelafuente/avanzosc/dos_services_to_invoice/+merge/224422
Your team Avanzosc_security is requested to review the proposed merge of lp:~alfredodelafuente/avanzosc/dos_services_to_invoice into lp:~avanzosc-security-team/avanzosc/72horas.
=== modified file 'dos_services_to_invoice/__init__.py'
--- dos_services_to_invoice/__init__.py	2014-06-11 10:23:47 +0000
+++ dos_services_to_invoice/__init__.py	2014-06-25 11:35:10 +0000
@@ -18,10 +18,4 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
-
-
-import product
-import sale
-import sale_order_line
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+from . import models
\ No newline at end of file

=== modified file 'dos_services_to_invoice/__openerp__.py'
--- dos_services_to_invoice/__openerp__.py	2014-06-11 10:23:47 +0000
+++ dos_services_to_invoice/__openerp__.py	2014-06-25 11:35:10 +0000
@@ -18,20 +18,19 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
-
-
 {
-    "name" : "DOS Services To Invoice",
-    "version" : "1.0",
-    "author" : "DOS",
-    "category" : "Product, Sales",
-    "website" : "www.dos-sl.es",
-    "description": "This module allows you to add services to invoice on the products.",
-    "depends" : ['product', 'sale', 'dos_stock_warehouse_additional_info', 'dos_product_additional_info'],
-    "init_xml" : [],
-    "update_xml" : ['product_view.xml', 'sale_order_line_view.xml'],
+    "name": "DOS Services To Invoice",
+    "version": "1.0",
+    "author": "DOS",
+    "category": "Product, Sales",
+    "website": "www.dos-sl.es",
+    "description": """
+    This module allows you to add services to invoice on the products.
+    """,
+    "depends": ['product', 'sale', 'dos_stock_warehouse_additional_info',
+                'dos_product_additional_info',
+                ],
+    "data": ['view/product_view.xml', 'view/sale_order_line_view.xml'],
     "active": False,
     "installable": True
 }
-
-

=== added directory 'dos_services_to_invoice/models'
=== added file 'dos_services_to_invoice/models/__init__.py'
--- dos_services_to_invoice/models/__init__.py	1970-01-01 00:00:00 +0000
+++ dos_services_to_invoice/models/__init__.py	2014-06-25 11:35:10 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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/>.
+#
+##############################################################################
+from . import product
+from . import sale
\ No newline at end of file

=== added file 'dos_services_to_invoice/models/product.py'
--- dos_services_to_invoice/models/product.py	1970-01-01 00:00:00 +0000
+++ dos_services_to_invoice/models/product.py	2014-06-25 11:35:10 +0000
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
+
+
+class ProductProduct(orm.Model):
+    _inherit = 'product.product'
+
+    _columns = {
+        'product_services_ids': fields.many2many('product.product',
+                                                 'product_services_rel',
+                                                 'product_id',
+                                                 'product_service_id',
+                                                 'Services',
+                                                 help="This is the list "
+                                                 "of services to be invoiced "
+                                                 "after the sale of the "
+                                                 "product."),
+    }

=== added file 'dos_services_to_invoice/models/sale.py'
--- dos_services_to_invoice/models/sale.py	1970-01-01 00:00:00 +0000
+++ dos_services_to_invoice/models/sale.py	2014-06-25 11:35:10 +0000
@@ -0,0 +1,133 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 DOS (<http://www.dos-sl.es>).
+#
+#    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/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
+from . import time
+
+
+class SaleOrder(orm.Model):
+    _inherit = 'sale.order'
+
+    def action_ship_create(self, cr, uid, ids, *args):
+        result = super(SaleOrder, self).action_ship_create(cr, uid, ids, *args)
+        stock_move_obj = self.pool['stock.move']
+        for order in self.browse(cr, uid, ids, context={}):
+            output_id = order.shop_id.warehouse_id.lot_rented_id.id
+            for line in order.order_line:
+                # Si el producto es alquilado
+                if line.rented:
+                    # Buscamos líneas de albarán generadas del pedido
+                    condition = [('sale_line_id', '=', line.id)]
+                    stock_move_ids = stock_move_obj.search(cr, uid, condition)
+                    # Modificamos líneas de albarán con ubicación de alquilados
+                    vals = {'location_dest_id': output_id}
+                    stock_move_obj.write(cr, uid, stock_move_ids, vals)
+        return result
+
+
+class SaleOrderLine(orm.Model):
+    _inherit = 'sale.order.line'
+
+    _columns = {
+        'rented': fields.boolean('Rental', select=True, help="Indicates if "
+                                 "the product is going to be rented."),
+    }
+
+    def rented_change(self, cr, uid, ids, product_id, contract_id=False,
+                      num_cabins=0, rented=False):
+        result = {}
+        domain = {}
+        warning = {}
+        result['price_unit'] = False
+        result['discount'] = False
+        if product_id and contract_id:
+            product_obj = self.pool['product.product']
+            contract_obj = self.pool['contract.contract']
+            product = product_obj.browse(cr, uid, product_id)
+            contract = contract_obj.browse(cr, uid, contract_id)
+            # Precio producto si es una sim
+            if product_obj._is_sim(product.categ_id):
+                # Obtenemos precios segun reglas definidas
+                fixedprice = contract_obj.get_fixed_price(cr, uid, contract.id,
+                                                          product.id)
+                extcabinprice = contract_obj.get_extra_cabin_price(cr, uid,
+                                                                   contract.id,
+                                                                   product.id)
+                diff_price = contract_obj.get_differential_price(cr, uid,
+                                                                 contract.id,
+                                                                 product.id)
+                price_cabins = num_cabins > 1 and ((num_cabins - 1) *
+                                                   extcabinprice) or 0
+                price_unit = fixedprice + price_cabins
+                discount = diff_price or 0
+            # Precio producto si es un enlace
+            elif product_obj._is_link(product.categ_id):
+                # Obtenemos precios segun reglas definidas
+                fixlink_price = contract_obj.get_fixed_link_price(cr, uid,
+                                                                  contract.id,
+                                                                  None,
+                                                                  product.id)
+                lkprice = contract_obj.get_differential_link_price(cr, uid,
+                                                                   contract.id,
+                                                                   None,
+                                                                   product.id)
+                price_unit = fixlink_price or product.list_price
+                # El tipo de venta no es un requisito para aplicar el descuento
+                # discount = rented and differential_link_price or 0
+                discount = lkprice or 0
+            # Precio producto si es un pack
+            elif product_obj._is_pack(product.categ_id):
+                prodsim_id, prodlink_id = product_obj.pack_components(product)
+                # Obtenemos precios segun reglas definidas
+                fixedprice = contract_obj.get_fixed_price(cr, uid, contract.id,
+                                                          prodsim_id,
+                                                          prodlink_id)
+                cabin_price = contract_obj.get_extra_cabin_price(cr, uid,
+                                                                 contract.id,
+                                                                 prodsim_id,
+                                                                 prodlink_id)
+                diff_price = contract_obj.get_differential_price(cr, uid,
+                                                                 contract.id,
+                                                                 prodsim_id,
+                                                                 prodlink_id)
+                fixlinkprice = contract_obj.get_fixed_link_price(cr, uid,
+                                                                 contract.id,
+                                                                 prodsim_id,
+                                                                 prodlink_id)
+                dlprice = contract_obj.get_differential_link_price(cr, uid,
+                                                                   contract.id,
+                                                                   prodsim_id,
+                                                                   prodlink_id)
+                extra_cabin = ((num_cabins - 1) * cabin_price)
+                price_cabins = num_cabins > 1 and extra_cabin or 0
+                price_sim = fixedprice + price_cabins
+                price_sim = price_sim - (price_sim * diff_price / 100)
+                price_link = fixlinkprice or product.list_price
+                # El tipo de venta no es un requisito para aplicar el descuento
+                # if rented:
+                price_link2 = (price_link * dlprice / 100)
+                price_link = price_link - price_link2
+                price_unit = price_sim + price_link
+                discount = 0
+            result['price_unit'] = price_unit
+            result['discount'] = discount
+        return {'value': result, 'domain': domain, 'warning': warning}

=== removed file 'dos_services_to_invoice/product.py'
--- dos_services_to_invoice/product.py	2014-06-11 10:23:47 +0000
+++ dos_services_to_invoice/product.py	1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
-#
-#    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/>.
-#
-##############################################################################
-
-from osv import osv, fields
-import re
-from tools.translate import _
-
-class product_product(osv.osv):
-
-	_name = 'product.product'
-	_inherit = 'product.product'
-	
-	_columns = {
-		'product_services_ids': fields.many2many('product.product', 'product_services_rel', 'product_id', 'product_service_id', 'Services', help="This is the list of services to be invoiced after the sale of the product."),
-	}
-
-product_product()

=== removed file 'dos_services_to_invoice/product_view.xml'
--- dos_services_to_invoice/product_view.xml	2014-06-11 10:23:47 +0000
+++ dos_services_to_invoice/product_view.xml	1970-01-01 00:00:00 +0000
@@ -1,24 +0,0 @@
-<?xml version="1.0"?>
-<openerp>
-	<data> 
-	
-		<!-- Product Inherit Form View -->
-		<record id="view_product_services_form" model="ir.ui.view">
-			<field name="name">product.services.form</field>
-			<field name="model">product.product</field>
-			<field name="inherit_id" ref="product.product_normal_form_view"/>
-			<field name="type">form</field>
-			<field name="arch" type="xml">
-				<page string="Packaging" position="after">
-					<page string="Services">
-						<field name="product_services_ids" 
-							   colspan="4" 
-							   domain="[('type','=','service')]" 
-							   nolabel="1" 
-						/>
-					</page>
-				</page>
-			</field>
-		</record>
-	</data>
-</openerp>

=== removed file 'dos_services_to_invoice/sale.py'
--- dos_services_to_invoice/sale.py	2014-06-11 10:23:47 +0000
+++ dos_services_to_invoice/sale.py	1970-01-01 00:00:00 +0000
@@ -1,46 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2010 DOS (<http://www.dos-sl.es>).
-#
-#    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/>.
-#
-##############################################################################
-
-from osv import osv
-from osv import fields
-from tools.translate import _
-
-
-class sale_order(osv.osv):
-
-	_inherit ="sale.order"
-	
-
-	def action_ship_create(self, cr, uid, ids, *args):
-		result = super(sale_order, self).action_ship_create(cr, uid, ids, *args)
-		stock_move_obj = self.pool.get('stock.move')
-		for order in self.browse(cr, uid, ids, context={}):
-			output_id = order.shop_id.warehouse_id.lot_rented_id.id
-			for line in order.order_line:
-				#Si el producto es alquilado
-				if line.rented:
-					#Buscamos líneas de albarán generadas del pedido
-					stock_move_ids = stock_move_obj.search(cr, uid, [('sale_line_id', '=', line.id)])
-					#Modificamos líneas de albarán con ubicación de alquilados
-					stock_move_obj.write(cr, uid, stock_move_ids, {'location_dest_id': output_id})
-		return result
-		
-sale_order()
\ No newline at end of file

=== removed file 'dos_services_to_invoice/sale_order_line.py'
--- dos_services_to_invoice/sale_order_line.py	2014-06-11 10:23:47 +0000
+++ dos_services_to_invoice/sale_order_line.py	1970-01-01 00:00:00 +0000
@@ -1,116 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2010 DOS (<http://www.dos-sl.es>).
-#
-#    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/>.
-#
-##############################################################################
-
-from osv import osv
-from osv import fields
-from tools.translate import _
-import time
-
-class sale_order_line(osv.osv): 
-
-	_name = 'sale.order.line'
-	_inherit = 'sale.order.line'
-	
-	_columns = {
-		'rented': fields.boolean('Rental', select=True, help="Indicates if the product is going to be rented."),
-	}
-	
-	def rented_change(self, cr, uid, ids, product_id, contract_id=False, num_cabins=0, rented=False):
-	
-		result = {}
-		domain = {}
-		warning = {}
-		
-		result['price_unit'] = False
-		result['discount'] = False
-		
-		if product_id and contract_id:
-			
-			product_obj = self.pool.get('product.product')
-			contract_obj = self.pool.get('contract.contract')
-			
-			product = product_obj.browse(cr, uid, product_id)
-			contract = contract_obj.browse(cr, uid, contract_id)
-			
-			# Precio producto si es una sim
-			if product_obj._is_sim(product.categ_id):
-				#Obtenemos precios segun reglas definidas
-				fixed_price = contract_obj.get_fixed_price(cr, uid, contract.id, product.id)
-				extra_cabin_price = contract_obj.get_extra_cabin_price(cr, uid, contract.id, product.id)
-				differential_price = contract_obj.get_differential_price(cr, uid, contract.id, product.id)
-				
-				price_cabins = num_cabins > 1 and ((num_cabins -1) * extra_cabin_price) or 0
-				price_unit = fixed_price + price_cabins
-				discount = differential_price or 0
-				
-			# Precio producto si es un enlace
-			elif product_obj._is_link(product.categ_id):
-				#Obtenemos precios segun reglas definidas
-				fixed_link_price = contract_obj.get_fixed_link_price(cr, uid, contract.id, None, product.id)
-				differential_link_price = contract_obj.get_differential_link_price(cr, uid, contract.id, None, product.id)
-				
-				price_unit = fixed_link_price or product.list_price
-				
-				# El tipo de venta no es un requisito para aplicar el descuento
-				# discount = rented and differential_link_price or 0
-				discount = differential_link_price or 0
-				
-			# Precio producto si es un pack
-			elif product_obj._is_pack(product.categ_id):
-				
-				product_sim_id, product_link_id = product_obj.pack_components(product)
-				
-				#Obtenemos precios segun reglas definidas
-				fixed_price = contract_obj.get_fixed_price(cr, uid, contract.id, product_sim_id, product_link_id)
-				extra_cabin_price = contract_obj.get_extra_cabin_price(cr, uid, contract.id, product_sim_id, product_link_id)
-				differential_price = contract_obj.get_differential_price(cr, uid, contract.id, product_sim_id, product_link_id)
-				fixed_link_price = contract_obj.get_fixed_link_price(cr, uid, contract.id, product_sim_id, product_link_id)
-				differential_link_price = contract_obj.get_differential_link_price(cr, uid, contract.id, product_sim_id, product_link_id)
-				
-				price_cabins = num_cabins > 1 and ((num_cabins -1) * extra_cabin_price) or 0
-				price_sim = fixed_price + price_cabins
-				price_sim = price_sim - (price_sim * differential_price / 100)
-				
-				price_link = fixed_link_price or product.list_price
-				
-				# El tipo de venta no es un requisito para aplicar el descuento
-				# if rented:
-				price_link = price_link - (price_link * differential_link_price / 100)
-				
-				price_unit = price_sim + price_link
-				discount = 0
-
-
-			result['price_unit'] = price_unit
-			result['discount'] = discount
-			
-		return {'value': result, 'domain': domain, 'warning': warning}
-	
-sale_order_line()
-	
-
-
-
-
-
-
-
-

=== removed file 'dos_services_to_invoice/sale_order_line_view.xml'
--- dos_services_to_invoice/sale_order_line_view.xml	2014-06-11 10:23:47 +0000
+++ dos_services_to_invoice/sale_order_line_view.xml	1970-01-01 00:00:00 +0000
@@ -1,23 +0,0 @@
-<?xml version="1.0"?>
-<openerp>
-	<data> 
-	
-		<!-- Sale Order Inherit Form View -->
-		<record model="ir.ui.view" id="view_order_rented_line_form_inherit">
-			<field name="name">sale.order.rended.line.form.inherit</field>
-			<field name="model">sale.order</field>
-			<field name="inherit_id" ref="sale_layout.view_order_form_inherit_1"/>
-			<field name="type">form</field>
-			<field name="priority">1</field>
-			<field name="arch" type="xml">
-				<xpath expr="/form/notebook/page/field[@name='abstract_line_ids']/form/notebook/page/field[@name='product_packaging']" position="after">		
-					<field name="rented" on_change="rented_change(product_id, parent.contract_id, num_cabins, rented)" />	
-                </xpath> 
-                <xpath expr="/form/notebook/page/field[@name='abstract_line_ids']/tree/field[@name='price_subtotal']" position="after">		
-					<field name="rented" />	
-                </xpath> 
-			</field>
-		</record>
-		
-	</data>
-</openerp>

=== added directory 'dos_services_to_invoice/views'
=== added file 'dos_services_to_invoice/views/product_view.xml'
--- dos_services_to_invoice/views/product_view.xml	1970-01-01 00:00:00 +0000
+++ dos_services_to_invoice/views/product_view.xml	2014-06-25 11:35:10 +0000
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<openerp>
+	<data> 
+	
+		<!-- Product Inherit Form View -->
+		<record id="view_product_services_form" model="ir.ui.view">
+			<field name="name">product.services.form</field>
+			<field name="model">product.product</field>
+			<field name="inherit_id" ref="product.product_normal_form_view"/>
+			<field name="arch" type="xml">
+				<page string="Packaging" position="after">
+					<page string="Services">
+						<field name="product_services_ids" colspan="4" 
+							   domain="[('type','=','service')]" nolabel="1" /> 
+					</page>
+				</page>
+			</field>
+		</record>
+	</data>
+</openerp>

=== added file 'dos_services_to_invoice/views/sale_order_line_view.xml'
--- dos_services_to_invoice/views/sale_order_line_view.xml	1970-01-01 00:00:00 +0000
+++ dos_services_to_invoice/views/sale_order_line_view.xml	2014-06-25 11:35:10 +0000
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<openerp>
+	<data> 
+	
+		<!-- Sale Order Inherit Form View -->
+		<record model="ir.ui.view" id="view_order_rented_line_form_inherit">
+			<field name="name">sale.order.rended.line.form.inherit</field>
+			<field name="model">sale.order</field>
+			<field name="inherit_id" ref="sale_layout.view_order_form_inherit_1"/>
+			<field name="priority">1</field>
+			<field name="arch" type="xml">
+				<field name="product_packaging" position="after">
+					<field name="rented" on_change="rented_change(product_id, parent.contract_id, num_cabins, rented)" />
+				</field>
+				<field name="price_subtotal" position="after">
+					<field name="rented" />
+				</field>
+			</field>
+		</record>
+		
+	</data>
+</openerp>


Follow ups