-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaterials.py
54 lines (45 loc) · 1.7 KB
/
materials.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from datetime import datetime, time
from dateutil.relativedelta import relativedelta
from itertools import groupby
from pytz import timezone, UTC
from werkzeug.urls import url_encode
from odoo import api, fields, models, _
from odoo.osv import expression
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
from odoo.tools.float_utils import float_is_zero
from odoo.exceptions import AccessError, UserError, ValidationError
from odoo.tools.misc import formatLang, get_lang
class Materials(models.Model):
_name = 'materials'
_description = 'Material List'
name = fields.Char(string='Name', required=True)
code = fields.Char(string='Code', required=True)
type = fields.Selection([
('fabric', 'Fabric') ,
('jeans', 'Jeans') ,
('cotton', 'Cotton') ,
], string='Type', required=True)
price = fields.Float(string='Buy Price', required=True, default=100.000) #Price in IDR
supplier_name = fields.Many2one('suppliers', string='Supplier', required=True)
picture = fields.Image(string="Image")
# exported = fields.Many2one('material.order',string="")
# @api.model
# def create(self, vals_list):
# res = super().create(vals_list)
# vals_list = {
# 'name' : res.name
# }
# self.env['material.order'].create(vals_list)
# return res
# def confirm_order(self):
# vals = {
# 'name' : self.name
# }
# self.env['material.order'].create(vals)
@api.constrains('price')
def check_price(self):
for record in self:
if record.price < 100.000:
raise ValidationError(("Price Cannot less than IDR 100.000."))
else :
True