Hi, All
I am Using Odoo 11.0 C.E.
I Crated a new module
Here is my Functions:
When I am trying to Upgrade the Module it shows me the following error:
File "E:\odoo-11.0\addons\stock_br\models\stockpicking.py", line 20, in _amount_all File "E:\odoo-11.0\odoo\fields.py", line 945, in __get__ record.ensure_one() File "E:\odoo-11.0\odoo\models.py", line 4267, in ensure_one raise ValueError("Expected singleton: %s" % self) ValueError: Expected singleton: stock.picking(13, 3, 2, 1, 7, 6, 5, 4, 9, 8, 12, 11, 10, 14, 17, 16, 15, 19, 18, 20)
class StockMove(models.Model):
_inherit = "stock.move"
currency_id = fields.Many2one(related='picking_id.currency_id', store=True, string='Currency', readonly=True)
price_total = fields.Monetary(compute='_compute_amount', string='Total', store=True)
@api.depends('product_qty', 'price_unit')
def _compute_amount(self):
for line in self:
total = 0.0
total = line.product_qty * line.price_unit
line.update({
'price_total': total,
})
class StockMoveLines(models.Model):
_inherit = "stock.move.line"
currency_id = fields.Many2one(related='picking_id.currency_id', store=True, string='Currency', readonly=True)
price_unit = fields.Float(string='Unit Price', required=True, digits=dp.get_precision('Product Price'))
price_total = fields.Monetary(compute='_compute_amount', string='Total', store=True)class StockPicking(models.Model):
_inherit = "stock.picking"
currency_id = fields.Many2one('res.currency', 'Currency', readonly=True,default=lambda self: self.env.user.company_id.currency_id.id)
amount_total = fields.Monetary(string='Total', store=True, readonly=True, compute='_amount_all')
total_amount_in_words = fields.Char(string="Amount in Words", store=True, compute='_amount_all')
@api.depends('move_lines.price_total')
def _amount_all(self):
for picking in self:
amount_total = 0.0
for line in picking.move_lines:
amount_total += line.price_total
lang = self.partner_id and self.partner_id.lang[:2]
try:
test = num2words(42, lang=lang)
except NotImplementedError:
lang = 'en'
numword = num2words(amount_total , lang=lang)
picking.update({
'amount_total': amount_total,
'total_amount_in_words': numword,
})
Yenthe
Thanks a lot, it works
You're welcome, best of luck!