Odoo Ayuda

0

0
9 Answers
2
Avatar

Akhil P Sivan

--Akhil P Sivan--

4134
| 6 4 9
Kochi, India
--Akhil P Sivan--

Odoo Developer

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
29/1/17 6:07

Hi,

I think the problem is with the way you have set domain variable.

Please try like this:

@api.multi    
def generate_purchase_history(self):
    action = self.env.ref('purchase.action_purchase_line_product_tree')
    domain=[('product_id.id', '=', self.product_id.id)]
    return {
            'name': action.name,
            'help': action.help,
            'type': action.type,
            'view_type': action.view_type,
            'view_mode': action.view_mode,
            'target': action.target,
            'res_model': action.res_model,
            'domain': domain
            }

Hope this helps.

0
GiusyG
27/11/18 9:31

The correct domain is:

domain="[('product_id', '=', self.product_id.id)]"

0
Avatar

Jignesh Mehta

--Jignesh Mehta--
11319
| 7 6 10
Surat, India
--Jignesh Mehta--
General Summary :-
- Odoo (Formerly OpenERP) Technical & Functional Expert.
- Worked as Project lead on Jewellery Manufacturing ERP.
- Having 3+ years of strong experience in odoo module development.
- Work for 3+ odoo customization to international & national clients.

Module Developments :-
- Develop Jewellery Manufacturing ERP from Scratch.
- Work in Several Modules like CRM, Sales, Purchase, Account, Inventory HR, Payroll, Website, etc.
- Work in Odoo themes which is Business and E-commerce.

Report Development :-
- Develop several Qweb and Excel Reports.

Code Migration :-
- Migrate code from Odoo9.0 to Odoo12.0 of Jewellery Manufacturing ERP.
Jignesh Mehta
2/9/16 0:08

Hello Jithin,


In purchase order line, product's object is product.product and you taken here product.template

Try with take product.product instead of product.template


product_id = fields.Many2one('product.product', string ="Product")


Hope this will helps you.

Thanks,


0
Pravitha
12/1/17 2:55

I think you can't get "product_id" using "self.product_id"

Try something like this:

@api.multi
def generate_purchase_history(self):
for data in self:
     product = data.product_id.id
    action = self.env.ref('purchase.action_purchase_line_product_tree')
    domain= [('product_id', '=', product)]
    return {
        'name': action.name,
        'help': action.help,
        'type': action.type,
        'view_type': action.view_type,
        'view_mode': action.view_mode,
        'target': action.target,
        'res_model': action.res_model,
        'domain': domain
0

Hi Jithin,

Self is not defined error can occur when your indentation is not proper. so, check your indentation.

another one thing i am seeing in your code is return statement doesn't have ending  "}" .

0

domain="[('product_id', '=', self.product_id)]"

this domain set as string so view don't have self so remove "" from domain and do like

domain= [('product_id', '=', self.product_id)]


Thank you

0
Megha_SerpentCS
28/8/18 5:53

Jithin

It seems that syntax of domain is wrong, you can define like

domain = [('product_id.id', '=', self.product_id.id)]

one more thing, put your code inside the method.

Thank You.

0
Avatar
--deep--

Techno-Functional Associate with 7+ years of experience in Odoo (formerly known as OpenERP).

deep
27/11/18 9:14

Whenever a method is defined '@api.multi' it means, the method can accept a list of RecordSet, thus the param Self might hold list of BrowseRecords, in that case, Add a loop to do necessary.


@api.multi

def generate_purchase_history(self):

action = self.env.ref('purchase.action_purchase_line_product_tree')

ProductIds = []
for case in self:
     ProductIds.append(case.product_id.id)
 
domain= [('product_id', 'in',ProductIds )]
return {
        'name': action.name,
        'help': action.help,
        'type': action.type,
        'view_type': action.view_type,
        'view_mode': action.view_mode,
        'target': action.target,
        'res_model': action.res_model,
        'domain': domain
0
Avatar

Aktiv software

--Aktiv software--
4239
| 6 3 9
Ahmedabad, India
--Aktiv software--

Started off with a small number and here we are serving multiple Odoo development organizations as a backend technical and functional Odoo force.
Apart from various business-oriented goals, we as a team have strongly emphasized on serving the Odoo Community. Being into the development of the open-source community we continuously thrive to learn, share and contribute to Odoo. Odoo having 20,000+ people contributing to the community from around the globe, we are proud that we belong here.
Talking about our contribution to Odoo Community we have prepared over 50+ Aktiv app modules. Moreover, we have launched wide range of modules that enhance the out-of-box functionalities of Odoo and meets the real-time business scenarios.
-POS
-Project Management
-Website
-Accounting
-Sales
-Productivity
-Inventory
-Document Management
-Human Resources
-Payment module (Payment Reminder)
-User Accessibility (Sign Up with Mobile Number, Activity Log)
-Report Modules (PDF, Printing, Invoice)
All in all, we combine the ERP solutions to add icing on the cake thereby beautifying the base of default Odoo functionalities. So, raise the bar of your business with our Go-To Odoo Apps.
To know more about the latest trends and innovations in Odoo you can also stay in tune with our social media profiles and grab relevant inside scoops.
“Your rewards are always in direct proportion to your contribution”. Keep Sharing, Keep Growing!

Aktiv software
25/8/17 7:13

Hi,

Make proper indentation and Change 'product_id' field with relation 'product.product'. Like below :

 product_id = fields.Many2one('product.product')

@api.multi    
def generate_purchase_history(self):
    action = self.env.ref('purchase.action_purchase_line_product_tree')
    domain=[('product_id', '=', self.product_id)]        
    return {                
            'name': action.name,
            'help': action.help,
            'type': action.type,
            'view_type': action.view_type,
            'view_mode': action.view_mode,
            'target': action.target,
            'res_model': action.res_model,
            'domain': domain            
            }	
Realizar una pregunta
Writer
Keep Informed
1 seguidor(es)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now