11from odoo import models , fields , api
2- from odoo . exceptions import ValidationError
2+
33
44class PickupRequest (models .Model ):
55 _name = 'pickup.request'
66 _description = 'Pickup Request'
77 _inherit = ['mail.thread' , 'mail.activity.mixin' ]
88
9- name = fields .Char (string = 'Name' , required = True , default = 'New' , tracking = True )
10- customer_id = fields .Many2one ('res.partner' , string = 'Customer' , required = True , tracking = True )
11- request_date = fields .Date (string = 'Request Date' , default = fields .Date .context_today , required = True , tracking = True )
12- request_item_ids = fields .One2many ('pickup.request.item' , 'pickup_id' , string = 'Request Items' )
9+ name = fields .Char (
10+ string = 'Name' , required = True , default = 'New' , tracking = True
11+ )
12+ customer_id = fields .Many2one (
13+ 'res.partner' , string = 'Customer' , required = True , tracking = True
14+ )
15+ request_date = fields .Date (
16+ string = 'Request Date' , default = fields .Date .context_today ,
17+ required = True , tracking = True
18+ )
19+ request_item_ids = fields .One2many (
20+ 'pickup.request.item' , 'pickup_id' , string = 'Request Items'
21+ )
1322 notes = fields .Text (string = 'Notes' )
1423
1524 # New fields
16- product_id = fields .Many2one ('product.product' , string = 'Product' , required = True , tracking = True )
25+ product_id = fields .Many2one (
26+ 'product.product' , string = 'Product' , required = True , tracking = True
27+ )
1728 quantity = fields .Float (string = 'Quantity' , required = True , tracking = True )
18- lot_id = fields .Many2one ('stock.lot' , string = 'Lot' , domain = "[('product_id', '=', product_id)]" )
29+ lot_id = fields .Many2one (
30+ 'stock.lot' , string = 'Lot' ,
31+ domain = "[('product_id', '=', product_id)]"
32+ )
1933
2034 # Status tracking
2135 state = fields .Selection ([
@@ -28,10 +42,20 @@ class PickupRequest(models.Model):
2842
2943 # Additional fields for the view
3044 scheduled_date = fields .Date (string = 'Scheduled Date' , tracking = True )
31- warehouse_id = fields .Many2one ('stock.warehouse' , string = 'Warehouse' , tracking = True )
32- driver_id = fields .Many2one ('res.partner' , string = 'Driver' , domain = "[('is_company', '=', False)]" , tracking = True )
33- vehicle_id = fields .Many2one ('fleet.vehicle' , string = 'Vehicle' , tracking = True )
34- priority = fields .Selection ([('0' , 'Normal' ), ('1' , 'High' )], default = '0' , string = 'Priority' , tracking = True )
45+ warehouse_id = fields .Many2one (
46+ 'stock.warehouse' , string = 'Warehouse' , tracking = True
47+ )
48+ driver_id = fields .Many2one (
49+ 'res.partner' , string = 'Driver' ,
50+ domain = "[('is_company', '=', False)]" , tracking = True
51+ )
52+ vehicle_id = fields .Many2one (
53+ 'fleet.vehicle' , string = 'Vehicle' , tracking = True
54+ )
55+ priority = fields .Selection (
56+ [('0' , 'Normal' ), ('1' , 'High' )], default = '0' ,
57+ string = 'Priority' , tracking = True
58+ )
3559 signature = fields .Binary (string = 'Signature' )
3660 signed_by = fields .Many2one ('res.users' , string = 'Signed By' )
3761 signature_date = fields .Datetime (string = 'Signature Date' )
@@ -71,5 +95,8 @@ def action_cancel(self):
7195 def create (self , vals_list ):
7296 for vals in vals_list :
7397 if vals .get ('name' , 'New' ) == 'New' :
74- vals ['name' ] = self .env ['ir.sequence' ].next_by_code ('pickup.request' ) or 'New'
98+ vals ['name' ] = (
99+ self .env ['ir.sequence' ].next_by_code ('pickup.request' )
100+ or 'New'
101+ )
75102 return super ().create (vals_list )
0 commit comments