I'm totally a newbie here who love Odoo so much :)
I got stuck with this problem for a few days in Odoo CE 13.
I want my SHIPPING TYPE field which I made in sale.order can be used in purchase.order as well.
So I did this in shipping_type.py
# -*- coding: utf-8 -*-
from odoo import models, fields
class SaleOrder(models.Model):
_inherit = 'sale.order'
shipping_selection = [
('type1', 'Instant'),
('type2', 'Same Day'),
('type3', 'JNE'),
('type4', 'Tokopedia'),
('type5', 'Pick Up'),
('type6', 'AnterAja-Reguler'),
('type7', 'J&T-Reguler'),
('type8', 'Ninja-Reguler'),
]
shipping_type = fields.Selection(shipping_selection,'Shipping Type',)
Then, I was trying to make purchase_shipping_type.py in another addons, and created this:
# -*- coding: utf-8 -*-
from odoo import models, fields
class SaleOrder(models.Model):
_inherit = ['sale.order']
shipping_selection = [
('type1', 'Instant'),
('type2', 'Same Day'),
('type3', 'JNE'),
('type4', 'Tokopedia'),
('type5', 'Pick Up'),
('type6', 'AnterAja-Reguler'),
('type7', 'J&T-Reguler'),
('type8', 'Ninja-Reguler'),
]
shipping_type = fields.Selection(shipping_selection,'Shipping Type',)
class PurchaseOrder(models.Model):
_inherit = ['purchase.order']
shipping_type_purchase = fields.Selection(string='ShippingType',related=shipping_type.shipping_type_purhase, readonly=True)
This error showed up:
Aug 21 06:29:03 kama-odoo-server odoo13[24202]: NameError: name 'shipping_type' is not defined - - -
How to set up this properly? I really hope someone can help me :) Thanks!
@Niyas Raphy Sorry I don't have enough karma to comment on your answer. Thanks for providing the link, it's very useful. Basically, I just wanted to access the selection field (shipping_type in sales.order) and use it in purchase.order. What is the simplest solution for that?
I could see one line in the video:
patient_id = fields.Many2one('hospital.patient', string='Patient', required=True)
Is it possible if I use it like this:
shipping_type_purchase = fields.Selection('sale.order', string='ShippingType', required=True)