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

Is correct this method sintaxis? Please HELP

By
Charlie
on 2/26/16, 3:45 PM 389 views

Hello, I have a function that should validate that a product is of type ' Service' . When this condition is met the ' sequence' field must increase its value sequentially.  This method is written in the sale.order.line model.

Please if this function is badly implemented , tell me I can do to correct it.

I hope tips and suggestions thank you very much. Thanks

@api.depends('product_id.product_tmpl_id.type')

def _niu_validation(self):

    if product_id.product_tmpl_id.type == 'service':

          sequence= self.env['ir.sequence'].next_by_code('sale.order.line')

    return super(SaleOrderLine,self)

0

Axel Mendoza

--Axel Mendoza--
10318
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 2/26/16, 4:10 PM

@Charlie

No return is needed from that function and you should use self.product_id if you call it that function using a recordset(also take care of multiple records in the recorset like iterate over self) or pass the product_id to the function if you call the function directly, like:

@api.depends('product_id.product_tmpl_id.type')
def _niu_validation(self, product_id):
    if product_id.type == 'service':
          sequence= self.env['ir.sequence'].next_by_code('sale.order.line')

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: 2/26/16, 3:45 PM
Seen: 389 times
Last updated: 2/26/16, 4:10 PM