python flask api code
@product_api.route("/addproduct" , methods=['POST'])
@tryton.transaction()
def addproduct():
ProductTemplate.create([{'name': productname , 'type': type,'consumable':consumable, 'purchasable': purchasable , 'salable':salable , 'cost_price_method' : cost_price_method , 'cost_price' : cost_price , 'list_price': list_price , 'default_uom': 2 }])
product.template model
cost_price = fields.Function(fields.Numeric( "Cost Price", digits=price_digits,help="The amount it costs to purchase or make the product, " "or carry out the service."),'get_cost_price')
products = fields.One2Many( 'product.product', 'template', "Variants",help="The different variants the product comes in.")
def get_cost_price(self, name):
if len(self.products) == 1:
product, = self.products
return product.cost_price
how can i use setter function in tha tryton flask api ?