Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to add calculations to the sales quote

By
Carlos Carmona
on 9/2/14, 5:31 PM 1,293 views

I could add these fields to the form:

  <tree string = "Sales Order Lines" editable = "bottom">
    <field name = "x_alto" />
    <field name = "x_ancho" />
  </ tree>

according understand and to use these fields to make calculations in the file named sale.py in this part of code:

_columns = {
    'x_alto': fields.float ('sale.order.line', 'High'),
    'x_ancho': fields.float ('sale.order.line', 'W'),
}

and else where in this code:

class sale_order_line class (osv.osv):
     def _amount_line def (self, cr, uid, ids, field_name, arg, context = None):
         self.pool.get tax_obj = ('account.tax')
         self.pool.get cur_obj = ('res.currency')
         res = {}
         if context is None:
             context = {}
         for line in self.browse (cr, uid, ids, context = context):
             #MODIFIQUE THIS LINE WAS SO: price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
             price = line.price_unit * (1 - (line.discount or 0.0) / 100.0) * (* line.x_ancho line.x_alto)
             tax_obj.compute_all taxes = (cr, uid, line.tax_id, price, line.product_uom_qty, line.product_id, line.order_id.partner_id)
             cur = line.order_id.pricelist_id.currency_id
             res [line.id] = cur_obj.round (cr, uid, cur, taxes ['Total'])
         return res


but to update and create a new quote, I choose product measures and give that and I do not take intoaccount for calculating square meters, as entonses could do. The idea is to add a couple of fields for height and width and calculate the square footage in order to know how much to charge. Or otherwise do not know if there is any module that you can add and calculate the data I need.

0
Nicolás Visús
On 9/2/14, 9:36 PM

Hola Carlos, respondí algo parecido en la siguiente pregunta:

https://www.odoo.com/forum/help-1/question/need-help-with-quote-in-m2-45617

Espero que sea de ayuda.

 

ya veo, eso de espesificar las unidades de medida ya lo sabia pero si necesito carlcular metros cuadrados y su precio en base a estos. No se si el modulo de mrp me sirva. lo probe pero no aparece una opcion para cotizar lgun producto en metros cuadrados calculando esto. Investigando un poco encontre este nombre de modulo en la pagina de odoo que segun si permite estos calculos: product_lot_foundry pero solo esta para la version 5.0, intente instalarlo en la v7 para ver si lo instalaba pero no lo instala. Tambien agrege los campos para alto y ancho e intente modificar el codigo del modulo de sales (sales.py) en estas lineas de codigo: //en la clase de: class sale_order_line(osv.osv) de la funcion: def _amount_line(self, cr, uid, ids, field_name, arg, context=None): price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)*(line.x_alto*line.x_ancho) //y este codigo del diccionario (me parece que es un diccionario) _columns = { 'x_alto': fields.float('sale.order.line', 'Alto'), 'x_ancho': fields.float('sale.order.line', 'Ancho'), donde segun yo, es en donde realiza los calculos del total, impuestos, etc de las cotizaciones de venta, pero de igual manera no me hace el calculo. No habra alguna alguna otra forma para calcular esto?

Together Consulting, Carlos Carmona
on 9/3/14, 10:46 AM

Hi Nicholas Visús, just checked the links you sent me and have seen the module you have mentioned and I managed to add it in the addons folder and update the list of modules appears but if I try to install I get the following error: OpenERP Server Error Client Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/openerp/addons/web/http.py", line 204, in dispatch response["result"] = method(self, **self.params) File "/usr/lib/pymodules/python2.7/openerp/addons/web/controllers/main.py", line 1132, in call_button action = self._call_kw(req, model, method, args, {}) File "/usr/lib/pymodules/python2.7/openerp/addons/web/controllers/main.py", line 1120, in _call_kw return getattr(req.session.model(model), method)(*args, **kwargs) File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 42, in proxy result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw) File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 30, in proxy_method result = self.session.send(self.service_name, method, *args) File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 103, in send raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info) Server Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/usr/lib/pymodules/python2.7/openerp/addons/base/module/module.py", line 424, in button_immediate_install return self._button_immediate_function(cr, uid, ids, self.button_install, context=context) File "/usr/lib/pymodules/python2.7/openerp/addons/base/module/module.py", line 475, in _button_immediate_function _, pool = pooler.restart_pool(cr.dbname, update_module=True) File "/usr/lib/pymodules/python2.7/openerp/pooler.py", line 39, in restart_pool registry = RegistryManager.new(db_name, force_demo, status, update_module) File "/usr/lib/pymodules/python2.7/openerp/modules/registry.py", line 233, in new openerp.modules.load_modules(registry.db, force_demo, status, update_module) File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 354, in load_modules loaded_modules, update_module) File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 256, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 159, in load_module_graph load_openerp_module(package.name) File "/usr/lib/pymodules/python2.7/openerp/modules/module.py", line 405, in load_openerp_module __import__('openerp.addons.' + module_name) File "/usr/lib/pymodules/python2.7/openerp/modules/module.py", line 133, in load_module mod = imp.load_module('openerp.addons.' + module_part, f, path, descr) File "/usr/lib/pymodules/python2.7/openerp/addons/product_lot_foundry/__init__.py", line 20, in import product_lot_foundry File "/usr/lib/pymodules/python2.7/openerp/addons/product_lot_foundry/product_lot_foundry.py", line 26 _name = 'product.lot.foundry.heatcode' ^ IndentationError: expected an indented block how to might fix it?

Together Consulting, Carlos Carmona
on 9/5/14, 6:11 PM
0
Carlos Carmona
On 9/3/14, 10:45 AM

ya veo, eso de espesificar las unidades de medida ya lo sabia pero si necesito carlcular metros cuadrados y su precio en base a estos. No se si el modulo de mrp me sirva. lo probe pero no aparece una opcion para cotizar lgun producto en metros cuadrados calculando esto. Investigando un poco encontre este nombre de modulo en la pagina de odoo que segun si permite estos calculos: product_lot_foundry pero solo esta para la version 5.0, intente instalarlo en la v7 para ver si lo instalaba pero no lo instala. Tambien agrege los campos para alto y ancho e intente modificar el codigo del modulo de sales (sales.py) en estas lineas de codigo:

//en la clase de: class sale_order_line(osv.osv) de la funcion:  def _amount_line(self, cr, uid, ids, field_name, arg, context=None):

price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)*(line.x_alto*line.x_ancho)

//y este codigo del diccionario (me parece que es un diccionario) _columns = {

'x_alto': fields.float('sale.order.line', 'Alto'),
'x_ancho': fields.float('sale.order.line', 'Ancho'),

 

donde segun yo, es en donde realiza los calculos del total, impuestos, etc de las cotizaciones de venta, pero de igual manera no me hace el calculo.

No habra alguna alguna otra forma para calcular esto?

No sabría ayudarte con la programación en python. Te puedo decir que, nativamente, Odoo no ofrece esto que estás buscando. El módulo mrp no te va a servir porque, si entendí bien, lo que estás buscando tiene que ver con la venta. Concretamente necesitarías un desarrollo muy sencillo, básicamente una calculadora que multiplique alto x ancho. El módulo que hacés mención creo que te serviría aunque tiene un valor más: alto, ancho y grosor. Te dejo unos links que te pueden interesar: https://github.com/vnc-biz/openerp-extra-bundle/tree/master/product_lot_foundry http://huber.salazarcarlos.com/?p=339 https://www.odoo.com/forum/help-1/question/how-can-i-install-a-module-from-a-zip-file-5302

Nicolás Visús
on 9/5/14, 10:37 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 9/2/14, 5:31 PM
Seen: 1293 times
Last updated: 3/16/15, 8:10 AM