mirror of
https://github.com/bringout/oca-ocb-vertical-industry.git
synced 2026-04-25 06:12:02 +02:00
Initial commit: Vertical Industry packages
This commit is contained in:
commit
d5567a0017
766 changed files with 733028 additions and 0 deletions
30
odoo-bringout-oca-ocb-lunch/lunch/models/lunch_cashmove.py
Normal file
30
odoo-bringout-oca-ocb-lunch/lunch/models/lunch_cashmove.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.tools import float_round
|
||||
|
||||
|
||||
class LunchCashMove(models.Model):
|
||||
""" Two types of cashmoves: payment (credit) or order (debit) """
|
||||
_name = 'lunch.cashmove'
|
||||
_description = 'Lunch Cashmove'
|
||||
_order = 'date desc'
|
||||
|
||||
currency_id = fields.Many2one('res.currency', default=lambda self: self.env.company.currency_id, required=True)
|
||||
user_id = fields.Many2one('res.users', 'User',
|
||||
default=lambda self: self.env.uid)
|
||||
date = fields.Date('Date', required=True, default=fields.Date.context_today)
|
||||
amount = fields.Float('Amount', required=True)
|
||||
description = fields.Text('Description')
|
||||
|
||||
def name_get(self):
|
||||
return [(cashmove.id, '%s %s' % (_('Lunch Cashmove'), '#%d' % cashmove.id)) for cashmove in self]
|
||||
|
||||
@api.model
|
||||
def get_wallet_balance(self, user, include_config=True):
|
||||
result = float_round(sum(move['amount'] for move in self.env['lunch.cashmove.report'].search_read(
|
||||
[('user_id', '=', user.id)], ['amount'])), precision_digits=2)
|
||||
if include_config:
|
||||
result += user.company_id.lunch_minimum_threshold
|
||||
return result
|
||||
Loading…
Add table
Add a link
Reference in a new issue