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

Get integer values from Many2one field, and then compute it all

By
Farrell Raafi
on 12/5/15, 9:53 PM 636 views

Hello, I'm new to python... Now I'm just learning how to make a simple Odoo module...

Here's the model:

route.py

from openerp import models, fields
class CourierRoute(models.Model):
_name = 'courier.route'

name = fields.Char(string="Route", help="Format: Origin City > Destination City", required=True)
origin = fields.Many2one('courier.city', string="Origin City", required=True)
destination = fields.Many2one('courier.city', string="Destination City", required=True)
train = fields.Many2one('courier.train', string="Train", required=False)
cost_price = fields.Integer(string="Cost Price", required=False)
origin_price = fields.Integer(string="Origin City Shipment Price", readonly=True)
destination_price = fields.Integer(string="Destination City Shipment Price", readonly=True)
train_price = fields.Integer(string="Train Shipment Price", readonly=True)

city.py

from openerp import models, fields
class CourierCity(models.Model):
_name = 'courier.city'

name = fields.Char(string="City", required=True)
price = fields.Integer(string="Shipping Price", required=True)

train.py

from openerp import models, fields
class CourierTrain(models.Model):
_name = 'courier.train'

name = fields.Char(string="Train", help="Format: Origin Station > Destination Station", required=True)
price = fields.Integer(string="Shipping Price", required=True)


So I was creating a model for choosing necessary shipping route, and then compute all of the prices/cost that have been filled (some are not). But every time I want to make a def, I was confused by the cr,uid,and that such of things, I can't understand it.

Any help or advice is appreciated.

0
Farrell Raafi
On 12/6/15, 9:30 PM

Solved. I finally use related= in integer() and @api.depends to compute the total.

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: 12/5/15, 9:53 PM
Seen: 636 times
Last updated: 12/6/15, 9:30 PM