Pass value from sale order to delivery order :
- First, we need to inherit the objects and added fields.
- To inherit the sale order model or stock picking model and add fields in Odoo, you can follow these steps:
- Create a new module. The module should have a unique name and include all necessary files and directories.
- Define a new model: In the new module, create a new Python file and define a new model that inherits from the related model.
- Define your new fields in the class inheriting from the original model. You can add any type of field supported by Odoo, such as Char, Integer, Float, Boolean, Selection, Date, Datetime, Text, Binary, and many more. here we have added one field: a Char field.
For Inherit the sale order and add the field:
from odoo import models, fields
class SaleOrder(models.Model):
_inherit = 'sale.order'
description = fields.Char(string='Description')
For Inherit the stock move object and add the field:
from odoo import models, fields
class StockMove(models.Model):
_inherit = 'stock.move'
description = fields.Char(string='Description')
def _get_new_picking_values(self):
"""Inherit method for pass value from sale order to delivery order."""
res = super(StockMove, self)._get_new_picking_values()
res["description"] = self.group_id.sale_id.description
return res
These are the root methods for finding the original method for passing value from the sale order to the delivery order:
step1: def action_confirm(self): [module:sale, object:sale.order]
step2: def _action_confirm(self, merge=True, merge_into=False): [module:stock, object:stock.move]
step3: def _assign_picking(self): [module:stock, object:stock.move]
step4: def _get_new_picking_values(self): [module:stock, object:stock.move]
Pass value from sale order to invoice :
- First, we need to inherit the objects and added fields.
- To inherit the Sale Order model or account move model and add fields in Odoo, you can follow these steps:
- Create a new module. The module should have a unique name and include all necessary files and directories.
- Define a new model: In the new module, create a new Python file and define a new model that inherits from the related model.
- Define your new fields in the class inheriting from the original model. You can add any type of field supported by Odoo, such as Char, Integer, Float, Boolean, Selection, Date, Datetime, Text, Binary, and many more. here we have added one field: a Char field.
For Inherit the sale order and add the field:
from odoo import models, fields
class SaleOrder(models.Model):
_inherit = 'sale.order'
invoice_description = fields.Char(string='Invoice Description')
For Inherit the account move and add the field:
from odoo import models, fields
class AccountMove(models.Model):
_inherit = 'account.move'
invoice_description = fields.Char(string='Invoice Description')
Now passing the value from the sale order to the invoice, Here there are two methods for passing value.
one is for the regular invoice and another is for downpayment invoices.
1. Method for passing value from sale order to invoice(regular).
from odoo import models, fields
class SaleOrder(models.Model):
_inherit = 'sale.order'
invoice_description = fields.Char(string='Invoice Description')
def _prepare_invoice(self):
""" Method for passing value from sale order to regular invoice. """
res = super(SaleOrder, self)._prepare_invoice()
res["invoice_description"] = self.invoice_description
return res
These are the root methods for finding the original method for passing value from sale order to invoice(Regular):
step1: def create_invoices(self): [module:sale, object:sale.advance.payment.inv]
step2: def _create_invoices(self, grouped=False, final=False, date=None): [module:sale, object:sale.order]
step3: def _prepare_invoice(self): [module:sale, object:sale.order]
2. Method for passing value from sale order to invoice(downpayment invoices).
from odoo import models, fields
class SaleAdvancePaymentInv(models.TransientModel):
_inherit = 'sale.advance.payment.inv'
def _prepare_invoice_values(self, order, name, amount, so_line):
""" Method for passing value from sale order to regular invoice. """
res = super(SaleAdvancePaymentInv, self)._prepare_invoice_values(
order, name, amount, so_line
)
res.update({"invoice_description": order.invoice_description})
return res
These are the root methods for finding the original method for passing value from sale order to invoice(Downpayment):
step1: def create_invoices(self): [module:sale, object:sale.advance.payment.inv]
step2: def _create_invoices(self, grouped=False, final=False, date=None): [module:sale, object:sale.advance.payment.inv]
step3: def _prepare_invoice_values(self, order, name, amount, so_line): [module:sale, object:sale.advance.payment.inv]
Pass value from sale order to project and tasks :
- First, we need to inherit the objects and added fields.
- To inherit the Sale Order model or project or task model and add fields in Odoo, you can follow these steps:
- Create a new module. The module should have a unique name and include all necessary files and directories.
- Define a new model: In the new module, create a new Python file and define a new model that inherits from the related model.
- Define your new fields in the class inheriting from the original model. You can add any type of field supported by Odoo, such as Char, Integer, Float, Boolean, Selection, Date, Datetime, Text, Binary, and many more. here we have added one field: a Char field.
For Inherit the sale order and add the field:
from odoo import models, fields
class SaleOrder(models.Model):
_inherit = 'sale.order'
project_description = fields.Char(string='Project Description')
task_description = fields.Char(string='Task Description')
Now, added fields at the project level:
from odoo import models, fields
class Project(models.Model):
_inherit = 'project.project'
project_description = fields.Char(string='Project Description')
Now, added fields at the task level:
from odoo import models, fields
class ProjectTask(models.Model):
_inherit = 'project.task'
task_description = fields.Char(string='Task Description')
1. Method for passing value from sale order to project.
from odoo import models, fields
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
def _timesheet_create_project_prepare_values(self):
""" Inherit method for passing value from sale order to project. """
vals = super(SaleOrderLine, self)._timesheet_create_project_prepare_values()
vals["project_description"] = self.order_id.project_description
return vals
These are the root methods for finding the original method for passing value from the sale order to the project:
step1: def action_confirm(self): [module:sale, object:sale.order]
step2: def _action_confirm(self): [module:sale_project, object:sale.order]
step3: def _timesheet_service_generation(self): [module:sale_project, object:sale.order.line]
step4: def _timesheet_create_project(self): [module:sale_project, object:sale.order.line]
step5: def _timesheet_create_project_prepare_values(self): [module:sale_project, object:sale.order.line]
2. Method for passing value from sale order to task.
from odoo import models, fields
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
def _timesheet_create_task_prepare_values(self, project):
""" Inherit method for passing value from sale order to task. """
vals = super(SaleOrderLine, self)._timesheet_create_task_prepare_values(project)
vals["project_description"] = self.order_id.project_description
return vals
These are the root methods for finding the original method for passing value from the sale order to the task:
step1: def action_confirm(self): [module:sale, object:sale.order]
step2: def _action_confirm(self): [module:sale_project, object:sale.order]
step3: def _timesheet_service_generation(self): [module:sale_project, object:sale.order.line]
step4: def _timesheet_create_task(self, project):: [module:sale_project, object:sale.order.line]
step5: def _timesheet_create_task_prepare_values(self, project): [module:sale_project, object:sale.order.line]
Pass value from sale order to manufacturing order :
- First, we need to inherit the objects and added fields.
- To inherit the Sale Order model or project or task model and add fields in Odoo, you can follow these steps:
- Create a new module. The module should have a unique name and include all necessary files and directories.
- Define a new model: In the new module, create a new Python file and define a new model that inherits from the related model.
- Define your new fields in the class inheriting from the original model. You can add any type of field supported by Odoo, such as Char, Integer, Float, Boolean, Selection, Date, Datetime, Text, Binary, and many more. here we have added one field: a Char field.
For Inherit the sale order and add the field:
from odoo import models, fields
class SaleOrder(models.Model):
_inherit = 'sale.order'
mrp_description = fields.Char(string='Manufacturing Description')
Now Inherit mrp production and add the field:
from odoo import models, fields
class SaleOrder(models.Model):
_inherit = 'mrp.production'
mrp_description = fields.Char(string='Manufacturing Description')
For updating or passing the value in mrp, we need to inherit the two methods for the stock move and stock rule.
Inherit the method of stock move object:
from odoo import models, fields
class StockMove(models.Model):
_inherit = 'stock.move'
def _prepare_procurement_values(self):
val = super(StockMove, self)._prepare_procurement_values()
val["mrp_description"] = self.group_id.sale_id.mrp_description
return val
Inherit the method of stock rule object:
from odoo import models, fields
class StockRule(models.Model):
_inherit = 'stock.rule'
def _prepare_mo_vals(
self,
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
bom,
):
""" Method for passing value from sale order to manufacturing order. """
vals = super(StockRule, self)._prepare_mo_vals(
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
bom,
)
vals["mrp_description"] = values.get("mrp_description")
return vals
These are the root methods for finding the original method for passing value from the sale order to the manufacturing order:
step1: def action_confirm(self): [module:sale, object:sale.order]
step2: def _action_confirm(self): [module:sale_project, object:sale.stock]
step3: def _action_launch_stock_rule(self, previous_product_uom_qty=False):
step4: def _run_manufacture(self, procurements): [module:mrp, object:sale.rule]
step5: def _prepare_mo_vals(self, product_id, product_qty, product_uom, location_id, name, origin, company_id, values, bom): [module:mrp, object:sale.rule]
Pass value from sale order to purchase order :
- First, we need to inherit the objects and added fields.
- To inherit the Sale Order model or project or task model and add fields in Odoo, you can follow these steps:
- Create a new module. The module should have a unique name and include all necessary files and directories.
- Define a new model: In the new module, create a new Python file and define a new model that inherits from the related model.
- Define your new fields in the class inheriting from the original model. You can add any type of field supported by Odoo, such as Char, Integer, Float, Boolean, Selection, Date, Datetime, Text, Binary, and many more. here we have added one field: a Char field.
For Inherit the sale order and add the field:
from odoo import models, fields
class SaleOrder(models.Model):
_inherit = 'sale.order'
purchase_description = fields.Char(string='Purchase Description')
Now Inherit purchase order and add the field:
from odoo import models, fields
class SaleOrder(models.Model):
_inherit = 'purchase.order'
purchase_description = fields.Char(string='Purchase Description')
To update or pass the value in the purchase order, we need to inherit the two methods of stock move and stock rule.
Inherit the method of stock move object:
from odoo import models, fields
class StockMove(models.Model):
_inherit = 'stock.move'
def _prepare_procurement_values(self):
val = super(StockMove, self)._prepare_procurement_values()
val["sale"] = self.group_id.sale_id
return val
Inherit the method of stock rule object:
from odoo import models, fields
class StockRule(models.Model):
_inherit = 'stock.rule'
def _prepare_purchase_order(self, company_id, origins, values):
""" Method for passing value from sale order to purchase order. """
res = super()._prepare_purchase_order(company_id=company_id, origins=origins, values=values)
res['purchase_description'] = values[0].get("sale").purchase_description
return res
These are the root methods for finding the original method for passing value from the sale order to the purchase order:
step1: def action_confirm(self): [module:sale, object:sale.order]
step2: def _action_confirm(self): [module:sale_project, object:sale.stock]
step3: def _action_launch_stock_rule(self, previous_product_uom_qty=False):
step4: def _run_buy(self, procurements): [module:purchase_stock, object:sale.rule]
step5: def _prepare_purchase_order(self, company_id, origins, values): [module:purchase_stock, object:sale.rule]
Pass Value From Sale Order To Purchase, Delivery and Invoice Order.