I have created an order form that contain a one2many list to identify the products featured in this order ,and i want to make a autoincrement field to reference the products inside the order form
for ex : an order may contain 3 products , the first will be number "1" ,the second number"2" ... ,and i want it to be the same for every order
this is my .py file , but what i ve tried didn't work
#stapp
from openerp import models, fields
from odoo import api import xmlrpclib
server = "http://localhost:8069"
database = "test01"
usr = "malek"
pwd ="malek93/"
common = xmlrpclib.ServerProxy("{}/xmlrpc/2/common" .format(server))
uid = common.authenticate(database,usr,pwd, {})
odapi = xmlrpclib.ServerProxy("{}/xmlrpc/2/object" .format(server))
class bon_de_versement(models.Model):
_name = 'bondeversement'
imgg = fields.Binary(string="image" , filters=None)
name = fields.Char("Nom Complet")
prix = fields.Float(string="Prix",readonly=True, store=True, compute="_calcprix")
date = fields.Date("Date de debut")
note = fields.Text("Note")
nutrient_ids = fields.One2many('versement', 'product_id' , 'Nutrient')
article_ids = fields.One2many('bondeversement.article', 'product_id' , 'Article')
reste = fields.Float(string="Le reste", readonly=True ,store=True , compute="_reste")
@api.one
@api.depends('article_ids', 'article_ids.prix_article')
ids = odapi.execute_kw(db, uid, password,'bondeversement.article', 'search',
[[['product_id', '=', 'article_ids.product_id']]])
[record] = odapi.execute_kw(database, uid, pwd,'bondeversement.article', 'read', [ids])
nb = 1
for it in [record]:
ajout = odapi.execute_kw(database, uid, pwd, 'bondeversement.article', 'write',[[it], [{'article_nb': nb}])
nb+= 1
def _calcprix(self):
total = 0
for unit in self.article_ids:
total += unit.prix_article
self.prix = total
@api.one
@api.depends('nutrient_ids', 'nutrient_ids.montant')
def _reste(self):
restee = self.prix
for mealitem in self.nutrient_ids:
restee -= mealitem.montant
self.reste = restee
class versements(models.Model):
_name = 'versement'
product_id = fields.Integer("PID")
montant = fields.Float("Versement")
date = fields.Datetime("Date de versement")
class bondeversement_article(models.Model):
_name = 'bondeversement.article'
product_id = fields.Integer("PID")
article_nb = fields.Integer("Nb")
namee = fields.Selection(selection =[('bague','Bague'),('boucle','Boucle'),('bracelet','Bracelet'),('ceinture','Ceinture'),('chaine','Chaine'),('ensemble','Ensemble'),('gourmette','Gourmette'),('msayess','Msayess'),('parrure','Parrure'),('pendentif','Pendentif'),('wiz','El-Wiz'),('article_bebe','Article bebe'),('autre','Autre')], string='Article')
poids_article = fields.Float("Poids")
prix_article = fields.Float("Prix")