Skip to Content
Menu
This question has been flagged
2 Replies
3708 Views

Hello all

Sorry for my simple question, maybe,


- I created a small module call project to be able to see different informations related to a project,like sale order, purchase order, delivery, etc... I could add documents by my project form, and see all project i created on my tree view.

- I add on sale order a project number field by inherit. On this field i could add my project, no problem.


What I want to do is, when I add my project number to my sale order form, I could record the sale order number to my project record

- And in the other way when I add my sale order number in my project form, it will update my project number field in the sale order


Model to add project field in sale.order

class orders(models.Model):
_inherit = 'sale.order'

project_number = fields.Many2one('xxxx.project', string="Project #")
class project(models.Model):
_name = 'xxxx.project'
_description = '****'
_rec_name = 'project_seq'

project_seq = fields.Char(string='Project ID', required=True, copy=False, readonly=True, index=True, default='New')
project_name = fields.Char(string='Project Name', required=True)
project_branch_name = fields.Many2one('res.partner', string="Branch")
project_customer_name = fields.Many2one('res.partner', string="Client")
project_start_date = fields.Date(string='Project Date', default=datetime.today(), readonly=True, required=True)
project_purchase_order = fields.Many2one('purchase.order', string="Purchase Order #")
project_sale_order = fields.Many2one('sale.order', string="Sales Order #")

As I'm starting to dev on odoo, my dev level is really poor ;) If someone could explain me how to process will be really really cool :)

Let me now if you need more info to help me

Thanks a lot!!

Avatar
Discard
Best Answer

Hi,

Not clear what exactly you looks for, when user select a project in sale order and if you need to establish a relation from project to sale order, you can easily define a one2many field inside the project using this many2one field as the inverse field, so when user select the projects in sale.order it will listed/shown in the One2many field inside the project model.


As you are new to odoo, see how to add One2many field from here: How to Add One2many Fields In Odoo


If you don't like to go with the concept of the one2many field you can try to override the create/write method of sales and write values into the other model.


Thanks

Avatar
Discard
Author

Sorry, I had problem to reply on this forum before, couldn't send you a thanks but it's help me a lot at that time. So big thanks!

Author Best Answer

Hi @Niyas Raphy

Thanks a lot for your reply. I think you got the point. I will watch the video you sent to me. Actually what I want should be super simple, i'm just limited in my understanding of odoo and have a poor level in dev...
It's what I want.

- I go on my sale order form, I could add the number of my project,

- Then in my project view, I open a project form and I could find the number of my sale order.

For now I could add manually in both form the right document but no relation between them.

Thanks again and I will check that

Avatar
Discard